Baby Ehab is known for his love for a certain operation. He has an array aa of length nn, and he decided to keep doing the following operation on it:
- he picks 22 adjacent elements; he then removes them and places a single integer in their place: their bitwise XOR
#include <bits/stdc++.h> typedef long long ll; using namespace std; int main() { ios_base::sync_with_stdio(false); int t; cin>>t; while(t--){ int n;cin>>n; int *a=new int[n+1]; int sum=0; for(int i=1;i<=n;i++){ cin>>a[i];sum^=a[i]; } if(!sum){ cout<<"YES\n";continue; } int cnt=0; for(int i=1,j;i<=n;i=j+1){ j=i; int now=a[i]; while(j<n&&now!=sum){ j++; now^=a[j]; } if(now==sum)cnt++; } cout<<(cnt>2?"YES":"NO")<<"\n"; } }
Now he asks you if he can make all elements of the array equal. Since babies like to make your life harder, he requires that you leave at least 22 elements remaining.
The first line contains an integer tt (1≤t≤151≤t≤15) — the number of test cases you need to solve.
The first line of each test case contains an integers nn (2≤n≤20002≤n≤2000) — the number of elements in the array aa.
The second line contains nn space-separated integers a1a1, a2a2, ……, anan (0≤ai<2300≤ai<230) — the elements of the array aa.
If Baby Ehab can make all elements equal while leaving at least 22 elements standing, print "YES". Otherwise, print "NO".