#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
static const auto _____ = []() {
	// fast IO code : this I understand
	ios::sync_with_stdio(false);
	cout.tie(NULL);
	cin.tie(0);
	return 0;
}();
/******************** //    Macros  // ************************/
#define ll long long int
#define MAX 1000000
#define bitscount 32
#define mod 1000000007

int mpow(int base, int exp) {
	base %= mod;
	int result = 1;
	while(exp > 0) {
		if(exp & 1) result = ((ll)result * base) % mod;
		base = ((ll)base * base) % mod;
		exp >>= 1;
	}
	return result;
}
ll gcdExtended(ll a, ll b, ll *x, ll *y) { 
    if (a == 0) { 
        *x = 0, *y = 1; 
        return b; 
    } 
    ll x1, y1;
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
    return gcd; 
} 
ll modInverse(ll b, ll m) { 
    ll x, y;
    ll g = gcdExtended(b, m, &x, &y); 
    if (g != 1) 
        return -1; 
    return (x%m + m) % m; 
} 

struct st {
	int a, b;
};

bool sortfunc (pair<int,int> a, pair<int,int> b) {
	return a.first < b.first;
}
ll gcd(ll a, ll b) {
	return (b == 0) ? a : gcd(b, a%b);
}

int dx[] = {0, 1, -1, 0};
int dy[] = {-1, 0, 0, 1};
//..................................................

ll 	mini = INT_MAX;
ll 	allinterval(vector<int> &v, int n, int start, int result) {
	if(start == n)
		return result;
	int ored = 0;
	for(int i = start; i < n; ++i) {
		ored = ored | v[i];
		mini = min(mini , allinterval(v, n, i + 1, ored xor result)); 
	}
	return mini;
}
void testcase(){
	int n; 
	cin >> n;
	vector<int>v(n);
	for(int i = 0; i < n; ++i) {
		cin >> v[i];
	}
	ll ans = allinterval(v,n,0,0);
	cout << ans << endl;
		
}

int main()
{
	// int t;
	// cin >> t;
	// while (t--)
	// {
		testcase();
	// }
	return 0;
}

#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;

static const int  MAX_INT  = std::numeric_limits<int>::max();
static const long MAX_LONG = std::numeric_limits<long>::max();
static const ll   MAX_LL   = std::numeric_limits<long long>::max();

#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)

///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
template<class T> inline bool chMin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chMax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

///////////////////////////////////////////////////
// ------------------- main -------------------- //
///////////////////////////////////////////////////

struct mint {
    static const int mod = 1000000007;
    long long x; // typedef long long ll;
    mint(long long x = 0) :x((x%mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
std::istream& operator>>(std::istream& is, mint& a) { return is >> a.x; }
std::ostream& operator<<(std::ostream& os, const mint& a) { return os << a.x; }

void countNb(ll& res) {
    ll n, a, b; cin >> n >> a >> b;

    // ensure A <= B
    if (b < a) {
        ll tmp = a;
        a = b;
        b = tmp;
    }

    mint N(n), A(a), B(b);

    mint nbA = N - (A - 1); nbA = nbA * nbA;
    mint nbB = N - (B - 1); nbB = nbB * nbB;
    mint nbtotal = nbA * nbB;

    // dupulication: inside
    mint nbAb = B - (A - 1); nbAb = nbAb * nbAb;
    mint nbInside = nbAb * nbB;

    // cross
    mint cnt = 0;
    for (ll alpha = 1; alpha < a; ++alpha) {
        mint Alpha(alpha);
        mint nbCross = (B - A + Alpha * 2) * 4;
        mint nbIn = N - (B + Alpha - 1); nbIn = nbIn * nbIn;
        cnt += nbCross * nbIn;
    }

    mint count = nbtotal - nbInside - cnt;
    res = count.x;
}

void countNb2(ll& res) {
    mint N, A, B; cin >> N >> A >> B;
    ll nbSpace = N.x - A.x - B.x;
    mint x3 = (nbSpace >= 0) ? (N-A-B+2)*(N-A-B+1) : 0;
    mint x2 = (N-A+1)*(N-B+1) - x3;
    mint x1 = x2 * x2;
    mint total = (N-A+1)*(N-B+1) * (N-A+1)*(N-B+1);
    mint ans = total - x1;
    res = ans.x;
}


void Main() {
    ll T; cin >> T;
    vector<ll> res(T);
    for (ll i = 0; i < T; ++i) {
        countNb2(res[i]);
    }

    rep(i, T) {
        cout << res[i] << endl;
    }
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout << std::fixed << std::setprecision(15);
    Main();

    double tmp;
    cin >> tmp;

    return 0;
}
