// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define f(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define pie 3.14159265359
#define mp make_pair
#define ff first
#define ss second
#define rf(i,a,b) for(int i=a;i>=b;i--)
#define sc(a) scanf("%lld",&a)
#define pf printf
#define sz(a) (ll)(a.size())
#define psf push_front
#define ppf pop_front
#define ppb pop_back
#define pb push_back
#define pq priority_queue
#define all(s) s.begin(),s.end()
#define sp(a) setprecision(a)
#define rz resize
#define ld long double
#define inf 1e15
#define ub upper_bound
#define lb lower_bound
#define bs binary_search
#define eb emplace_back
#define out fflush(stdout);
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
vector<ll> a(n);
f(i,0,n)
cin>>a[i];
bool flag=1;
ll val=a[0];
f(i,1,n)
{
if(val==a[i] || (val|a[i])==a[i] || (val|a[i])==val)
{
// cout<<val<<' '<<(val|a[i])<<"\n";
flag=0;
break;
}
val|=a[i];
}
if(flag)
cout<<"YES\n";
else
cout<<"NO\n";
}
}
Ly8gI3ByYWdtYSBHQ0Mgb3B0aW1pemUoIk9mYXN0IikKLy8gI3ByYWdtYSBHQ0Mgb3B0aW1pemUgKCJ1bnJvbGwtbG9vcHMiKQovLyAjcHJhZ21hIEdDQyB0YXJnZXQoInNzZSxzc2UyLHNzZTMsc3NzZTMsc3NlNCxwb3BjbnQsYWJtLG1teCxhdngsdHVuZT1uYXRpdmUiKQojaW5jbHVkZTxiaXRzL3N0ZGMrKy5oPgojZGVmaW5lIGxsIGxvbmcgbG9uZwojZGVmaW5lIGYoaSxhLGIpIGZvcihpbnQgaT1hO2k8YjtpKyspCiNkZWZpbmUgbW9kIDEwMDAwMDAwMDcKI2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