#include
using namespace std;
#define debug puts("YES");
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define lrt int l,int r,int rt
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define mst(a,b) memset((a),(b),sizeof(a))
#define pii pair
#define fi first
#define se second
#define mk(x,y) make_pair(x,y)
const int mod=1e9+7;
const int maxn=55;
const int maxm=5e5+10;
const ll INF=1e18;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){
if(y==0) return x;
return gcd(y,x%y);
}
int n,m,a[maxn][maxn],b[maxn][maxn];
int main(){
ios::sync_with_stdio(false);/*
freopen("d://in.txt","r",stdin);
freopen("d://out.txt","w",stdout);*/
int t;cin>>t;
while(t--){
cin>>n>>m;
mst(a,0);
rep(i,0,n) rep(j,0,m) cin>>a[i][j];
int tx=0,ty=0;
rep(i,0,n){
int flg=1;
rep(j,0,m) if(a[i][j]) flg=0;
tx+=flg;
}
rep(i,0,m){
int flg=1;
rep(j,0,n) if(a[j][i]) flg=0;
ty+=flg;
}
tx=min(tx,ty);
if((tx&1)==0) cout<<"Vivek\n";
else cout<<"Ashish\n";
}
return 0;
}
#include
using namespace std;
#define debug puts("YES");
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define lrt int l,int r,int rt
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define mst(a,b) memset((a),(b),sizeof(a))
#define pii pair
#define fi first
#define se second
#define mk(x,y) make_pair(x,y)
const int mod=1e9+7;
const int maxn=5e4+10;
const int maxm=5e5+10;
const ll INF=1e18;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){
if(y==0) return x;
return gcd(y,x%y);
}
int t,n,flg=1;
int a[maxn],b[maxn],cnt[2];
int main(){
ios::sync_with_stdio(false);/*
freopen("d://in.txt","r",stdin);
freopen("d://out.txt","w",stdout);*/
cin>>t;
while(t--){
flg=1,mst(cnt,0);
cin>>n;
rep(i,0,n){
cin>>a[i];
if(i) if(a[i]>b[i];
cnt[b[i]]++;
}
if(flg==1) cout<<"Yes\n";
else{
if(cnt[0]&&cnt[1]) cout<<"Yes\n";
else cout<<"No\n";
}
}
return 0;
}
#include
using namespace std;
#define debug puts("YES");
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define lrt int l,int r,int rt
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define mst(a,b) memset((a),(b),sizeof(a))
#define pii pair
#define fi first
#define se second
#define mk(x,y) make_pair(x,y)
const int mod=1e9+7;
const int maxn=2e5+10;
const int maxm=5e5+10;
const ll INF=1e18;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){
if(y==0) return x;
return gcd(y,x%y);
}
int n,a[maxn],b[maxn],pos[maxn],cnt[maxn];
int main(){
ios::sync_with_stdio(false);/*
freopen("d://in.txt","r",stdin);
freopen("d://out.txt","w",stdout);*/
cin>>n;
rep(i,0,n) cin>>a[i];
rep(i,0,n){
cin>>b[i];
pos[b[i]]=i;
}
rep(i,0,n){
int dis=0;
if(i<=pos[a[i]]){
dis=pos[a[i]]-i;
}else{
dis=n-i+pos[a[i]];
}
cnt[dis]++;
}
int ans=-1;
rep(i,0,n) ans=max(ans,cnt[i]);
cout<
#include
using namespace std;
#define debug puts("YES");
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define lrt int l,int r,int rt
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define mst(a,b) memset((a),(b),sizeof(a))
#define pii pair
#define fi first
#define se second
#define mk(x,y) make_pair(x,y)
const int mod=1e9+7;
const int maxn=55;
const int maxm=5e5+10;
const ll INF=1e18;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){
if(y==0) return x;
return gcd(y,x%y);
}
int t,n,m,gx,gy;
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int judge(int x,int y){
if(x<0||x>=n) return 0;
if(y<0||y>=m) return 0;
return 1;
}
string s[maxn];
int vis[maxn][maxn],flg=0,cnt=0;
int bfs(int x,int y){
if(x<0) return 1;
queue p;while(!p.empty()) p.pop();
p.push(mk(x,y));
mst(vis,0);
int ret=0,flag=0;
while(!p.empty()){
int x=p.front().fi,y=p.front().se;
p.pop();
if(vis[x][y]) continue;
else vis[x][y]=1;
if(x==n-1&&y==m-1) flag=1;
if(s[x][y]=='G') ret++;
if(ret==cnt&&flag) return 1;
rep(i,0,4){
int tx=x+dx[i],ty=y+dy[i];
if(!judge(tx,ty)) continue;
if(s[tx][ty]=='#') continue;
p.push(mk(tx,ty));
}
}
if(ret==cnt&&flag) return 1;
return 0;
}
int main(){
ios::sync_with_stdio(false);/*
freopen("d://in.txt","r",stdin);
freopen("d://out.txt","w",stdout);*/
cin>>t;
while(t--){
gx=-1,gy=-1;
flg=cnt=0;///初始化
cin>>n>>m;
rep(i,0,n) cin>>s[i];
rep(i,0,n) rep(j,0,m) if(s[i][j]=='B'){
rep(k,0,4){
int x=i+dx[k],y=j+dy[k];
if(!judge(x,y)) continue;
if(s[x][y]=='G') flg=1;
else if(s[x][y]=='.') s[x][y]='#';
}
}
///cout<<"flg"<
#include
using namespace std;
#define debug puts("YES");
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define lrt int l,int r,int rt
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define mst(a,b) memset((a),(b),sizeof(a))
#define pii pair
#define fi first
#define se second
#define mk(x,y) make_pair(x,y)
const int mod=1e9+7;
const int maxn=5e2+10;
const int maxm=5e5+10;
const ll INF=1e18;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){
if(y==0) return x;
return gcd(y,x%y);
}
int n;
ll a[maxn],maxv=-1,ret=-1;
int main(){
ios::sync_with_stdio(false);/*
freopen("d://in.txt","r",stdin);
freopen("d://out.txt","w",stdout);*/
cin>>n;
rep(i,0,n) {cin>>a[i];maxv=max(maxv,a[i]);}
ret=maxv;
rep(i,0,n) ret=max(ret,(maxv|a[i]));
rep(i,0,n) rep(j,i+1,n) rep(k,j+1,n) ret=max(ret,((a[i]|a[j])|a[k]));
cout<
#include
using namespace std;
#define debug puts("YES");
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define lrt int l,int r,int rt
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define mst(a,b) memset((a),(b),sizeof(a))
#define pii pair
#define fi first
#define se second
#define mk(x,y) make_pair(x,y)
const int mod=1e9+7;
const int maxn=5e4+10;
const int maxm=5e5+10;
const ll INF=1e18;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){
if(y==0) return x;
return gcd(y,x%y);
}
int t,a[maxn],b[maxn],n;
vector p,q;
int main(){
ios::sync_with_stdio(false);/*
freopen("d://in.txt","r",stdin);
freopen("d://out.txt","w",stdout);*/
cin>>t;
while(t--){
cin>>n;
rep(i,1,n+1) cin>>a[i];
rep(i,1,n+1) cin>>b[i];
if(n&1) if(a[(n+1)/2]^b[(n+1)/2]){
cout<<"No\n";
continue;
}
p.clear(),q.clear();
rep(i,1,(n+1)/2+1){
if(a[i]>a[n-i+1]) swap(a[n-i+1],a[i]);
if(b[i]>b[n-i+1]) swap(b[n-i+1],b[i]);
p.push_back(mk(a[i],a[n-i+1]));
q.push_back(mk(b[i],b[n-i+1]));
}
sort(p.begin(),p.end());
sort(q.begin(),q.end());
if(p==q) cout<<"Yes\n";
else cout<<"No\n";
}
return 0;
}