/*if ((double) ((double)(clock() - cl)/(double)CLOCKS_PER_SEC)>1.85) {break;}*/
//#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define double long double
#define ft first
#define sc second
#define pb push_back
#define booost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cerr.tie(0);
#define all(x) (x).begin(),(x).end()
#define file(x) freopen(string(string((x)) + ".in").c_str(), "r", stdin); freopen(string(string((x)) + ".out").c_str(), "w", stdout);
#define GG cout << " OPA " << '\n';

using namespace std;
using namespace __gnu_pbds;
typedef pair <int, int> pi;
typedef tree <pair <int, pair <int, int> >, null_type, less<pair <int, pair <int, int> > >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 20 + 5;
const int K = 100;
const int P = 37;
const int INF = 1e12;
const double d_INF = 2000000000.0;
const double EPS = 1e-10;
const int MOD = 1e9 + 7;
const int LOG = 20;

int a[N];

void solve() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i ++) cin >> a[i];
    int ans = INF;
    for (int mask = 0; mask < (1 << n); mask ++) {
        int cur = 0;
        int res = 0;
        for (int i = 0; i < n; i ++) {
            cur |= a[i + 1];
            if (((mask >> i) & 1) == 1) res ^= cur, cur = 0;
        }
        res ^= cur;
        cur = 0;
        ans = min(ans, res);
    }
    cout << ans;
}

main () {
    int test = 1;
    booost;
//    cin >> test;
    while (test --) {
        solve();
    }
}

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

const int dx[4] = {+1, 0, -1, 0};
const int dy[4] = {0, -1, 0, +1};

ll solve(ll n, ll a, ll b)
{
    // for 1d
    ll nooverlap;
    if (n - a - b < 0)
        nooverlap = 0;
    else
        nooverlap = ((n - a - b + 2) * (n - a - b + 1)) % MOD;
    ll overlap = ((n - a + 1) * (n - b + 1) - nooverlap) % MOD;
    // for 2d
    ll overlap2d = (overlap * overlap) % MOD;
    ll all = (((n - a + 1) * (n - a + 1) % MOD) * ((n - b + 1) * (n - b + 1) % MOD)) % MOD;
    ll ans = ((all - overlap2d) % MOD + MOD) % MOD; // be careful of negative mod
    return ans;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int t;
    cin >> t;
    for (int i = 0; i < t; i++)
    {
        ll n, a, b;
        cin >> n >> a >> b;
        ll ans = solve(n, a, b);
        cout << ans << endl;
    }
}
