#include <iostream>
#include <vector>
#include <fstream>
#include <queue>
#include <algorithm>
#include <list>
#include <ctime>
#include <cstdio>
#include <stack>
#include <cstring>
#include <climits>
#include <cmath>
#include <string>
#include <functional>
#include <sstream>
#include <map>
#include <set>
#pragma comment(linker, "/STACK:100000000000000")
using namespace std;
#define For(i,a,b) for (int i=a; i<b; i++)
#define Rep(i,a) for (int i=0; i<a; i++)
#define ALL(v) (v).begin(),(v).end()
#define Set(a,x) memset((a),(x),sizeof(a))
#define EXIST(a,b) find(ALL(a),(b))!=(a).end()
#define Sort(x) sort(ALL(x))
#define UNIQUE(v) Sort(v); (v).resize(unique(ALL(v)) - (v).begin())
#define MP make_pair
#define SF scanf
#define PF printf
#define MAXN 1001
#define MOD 1000000007
#define Dbug cout<<"";
#define EPS 1e-8
#define timestamp(x) printf("Time : %.3lf s.\n", clock()*1.0/CLOCKS_PER_SEC)
typedef long long ll;
typedef pair<int,int> pii;
int n, arr[4][MAXN];
ll h[MAXN][MAXN][2], goal[MAXN], h2[MAXN], pw[MAXN];
ll x=1234567891, tmp[MAXN];
int main(){
//ios_base::sync_with_stdio(false);
//freopen("a.in","r",stdin);
int tc, cas=1;
SF("%d", &tc);
pw[0]=1;
For(i, 1, MAXN) pw[i]=pw[i-1]*x;
while (tc--)
{
SF("%d", &n);
ll sum=0;
Rep(i, 4) Rep(j, n)
{
SF("%d", &arr[i][j]);
sum+=arr[i][j];
}
if(sum%n)
{
PF("Case %d: No\n", cas++);
continue;
}
sum/=n;
bool pr=0;
Rep(i, n)
{
goal[i]=sum-arr[0][i];
if(goal[i]<0)
{
PF("Case %d: No\n", cas++);
pr=1;
break;
}
}
if(pr) continue;
Rep(i, n)
{
h2[i]=0;
Rep(j, n)
{
ll t=goal[j]-arr[3][(i+j)%n];
h2[i]*=x;
h2[i]+=t;
}
}
sort(h2, h2+n);
Rep(i, n)
{
Rep(j, n)
{
ll t=arr[1][j]+arr[2][(i+j)%n];
tmp[j]=t;
if(j) h[i][j][0]=h[i][j-1][0]*x+t;
else h[i][j][0]=t;
}
for(int j=n-1; j>=0; j--)
h[i][j][1]=pw[n-j-1]*tmp[j]+h[i][j+1][1];
}
Rep(i, n) Rep(j, n)
{
ll a=0, b;
if(j) a=h[i][j-1][0];
b=h[i][j][1];
ll t=b*pw[j]+a;
if(binary_search(h2, h2+n, t))
{
PF("Case %d: Yes\n", cas++);
pr=1;
i=n;
break;
}
}
if(pr) continue;
PF("Case %d: No\n", cas++);
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8ZnN0cmVhbT4KI2luY2x1ZGUgPHF1ZXVlPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8bGlzdD4KI2luY2x1ZGUgPGN0aW1lPgojaW5jbHVkZSA8Y3N0ZGlvPgojaW5jbHVkZSA8c3RhY2s+CiNpbmNsdWRlIDxjc3RyaW5nPgojaW5jbHVkZSA8Y2xpbWl0cz4KI2luY2x1ZGUgPGNtYXRoPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8ZnVuY3Rpb25hbD4KI2luY2x1ZGUgPHNzdHJlYW0+CiNpbmNsdWRlIDxtYXA+CiNpbmNsdWRlIDxzZXQ+CgojcHJhZ21hIGNvbW1lbnQobGlua2VyLCAiL1NUQUNLOjEwMDAwMDAwMDAwMDAwMCIpCgp1c2luZyBuYW1lc3BhY2Ugc3RkOwojZGVmaW5lICAgICBGb3IoaSxhLGIpICAgICAgICBmb3IgKGludCBpPWE7IGk8YjsgaSsrKQojZGVmaW5lICAgICBSZXAoaSxhKSAgICAgICAgICBmb3IgKGludCBpPTA7IGk8YTsgaSsrKQojZGVmaW5lICAgICBBTEwodikgICAgICAgICAgICAodikuYmVnaW4oKSwodikuZW5kKCkKI2RlZmluZSAgICAgU2V0KGEseCkgICAgICAgICAgbWVtc2V0KChhKSwoeCksc2l6ZW9mKGEpKQojZGVmaW5lICAgICBFWElTVChhLGIp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