stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include "bits/stdc++.h"

using namespace std;

#define ll long long int

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

#define rrep(i,n) for( int i = n; i >= 0; i-- )

#define REP(i,s,t) for( int i = s; i <= t; i++ )

#define RREP(i,s,t) for( int i = s; i >= t; i-- )

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define INF 2000000000

#define mod 1000000007

#define INF2 1000000000000000000





int main(void)

{

    cin.tie(0);

    ios::sync_with_stdio(false);

    int N; cin >> N;

    multiset<int> st;

    int a[100010];

    set<int> st2;

    rep(i, N) {

        cin >> a[i];

        st.insert(a[i]);

        st2.insert(a[i]);

    }

    if (st2.size() > 3) {

        cout << "No" << endl;

        return 0;

    }

    int num0 = a[0];

    int num1 = a[1];

    if (st2.size() > 1) {

        auto itr = st2.begin();

        num0 = *itr;

        itr++;

        num1 = *itr;

    }

    int s = num0;

    //dump(num0);

    //dump(num1);

    int t = num0 ^ num1;

    st.erase(st.find(num0));

    st.erase(st.find(num1));

    rep(i, N - 1) {

        if (i == N - 2) {

            if (t != s) {

                cout << "No" << endl;

                return 0;

            }

            break;

        }

        auto itr = st.find(t);

        if (itr == st.end()) {

            cout << "No" << endl;

            return 0;

        }

        

        st.erase(itr);

        num0 = num1;

        num1 = t;

        t = num0 ^ num1;

        //cout << t << endl;

    }

    cout << "Yes" << endl;



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.448637249864458x):
#include<stdio.h>

#include<algorithm>

#include<functional>

#include<cmath>

using namespace std;

long long  mod = 1000000007;

long long a[100000];

int main()

{

	int N;

	int count = 1;

	scanf("%d", &N);

	for (int i = 0; i < N; i++) {

		scanf("%lld", &a[i]);

	}

	sort(a, a + N);

	long long number = a[0];

	long long bit;

	int count0 = 1;

	int count1 = 0;

	int count2 = 0;

	if (N % 3 == 0) {

		if (a[0] == 0) {

			for (int i = 1; i < N; i++) {

				if (a[i] == 0) {

					count0++;

				}

				if (a[i] != number) {

					number = a[i];

					count++;

				}

			}

			if (count == 2 && count0 == N / 3) {

				printf("Yes");

				return 0;

			}

		}

		else {

			for (int i = 1; i < N; i++) {

				if (a[i] == a[0]) {

					count0++;

				}

				if (a[i] == a[N / 3]) {

					count1++;

				}

				if (a[i] == a[N / 3 * 2]) {

					count2++;

				}

				if (a[i] != number) {

					number = a[i];

					count++;

				}

			}

			if (count == 3 && count0 == N / 3 && count1 == N / 3 && count2 == N / 3) {

				bit = a[0] ^ a[N / 3];

				if (bit == a[N / 3 * 2]) {

					printf("Yes");

					return 0;

				}

			}

		}

	}

	count0 = 0;

	for (int i = 0; i < N; i++) {

		if (a[i] == 0) {

			count0++;

		}

	}

	if (count0 == N) {

		printf("Yes");

	}

	else {

		printf("No");

	}

	return 0;

}
// Slower C++ solution:
// -----------------------------------

// Author     : MatsuTaku

// Country    : Japan

// Created    : 04/26/20 20:17:32

// -----------------------------------



#include <bits/stdc++.h>



using namespace std;

using ll = long long;



int main() {

  cin.tie(nullptr); ios::sync_with_stdio(false);



  ll n,m,s; cin>>n>>m>>s;

  struct Train {

    ll s, c, d;

    Train(ll s,ll c,ll d):s(s),c(c),d(d){}

    bool operator>(const Train& x) const {return d>x.d;}

  };

  vector<Train> graph[n];

  for (int i = 0; i < m; i++) {

    ll u,v,a,b; cin>>u>>v>>a>>b; u--; v--;

    graph[u].emplace_back(v,a,b);

    graph[v].emplace_back(u,a,b);

  }

  for (int i = 0; i < n; i++) {

    int c,d; cin>>c>>d;

    graph[i].emplace_back(i,-c,d);

  }

  constexpr ll MAX = 2500;

  constexpr ll INF = 1e18;

  vector<array<ll, MAX+1>> dp(n);

  for (auto& arr:dp) arr.fill(INF);

  dp[0][min(s,MAX)] = 0;

  priority_queue<Train, vector<Train>, greater<>> qs;

  qs.emplace(0,s,0);

  while (not qs.empty()) {

    auto [s,c,d] = qs.top(); qs.pop();

    if (d > dp[s][min(c,MAX)]) continue;

    for (auto t:graph[s]) {

      if (c-t.c<0) continue;

      if (d+t.d >= dp[t.s][min(c-t.c,MAX)]) continue;

      dp[t.s][min(c-t.c,MAX)] = d+t.d;

      qs.emplace(t.s, c-t.c, d+t.d);

    }

  }

  for (int i = 1; i < n; i++) {

    cout << *min_element(dp[i].begin(), dp[i].end()) << endl;

  }



  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 2.2834082049463675x):
// -----------------------------------

// Author     : MatsuTaku

// Country    : Japan

// Created    : 04/26/20 20:17:32

// -----------------------------------



#include <bits/stdc++.h>



using namespace std;

using ll = long long;



int main() {

  cin.tie(nullptr); ios::sync_with_stdio(false);



  ll n,m,s; cin>>n>>m>>s;

  struct Train {

    ll s, c, d;

    Train(ll s,ll c,ll d):s(s),c(c),d(d){}

    bool operator>(const Train& x) const {return d>x.d;}

  };

  vector<Train> graph[n];

  for (int i = 0; i < m; i++) {

    ll u,v,a,b; cin>>u>>v>>a>>b; u--; v--;

    graph[u].emplace_back(v,a,b);

    graph[v].emplace_back(u,a,b);

  }

  for (int i = 0; i < n; i++) {

    int c,d; cin>>c>>d;

    graph[i].emplace_back(i,-c,d);

  }

  constexpr ll MAX = 200;

  constexpr ll INF = 1e18;

  vector<array<ll, MAX+1>> dp(n);

  for (auto& arr:dp) arr.fill(INF);

  dp[0][min(s,MAX)] = 0;

  priority_queue<Train, vector<Train>, greater<>> qs;

  qs.emplace(0,s,0);

  while (not qs.empty()) {

    auto [s,c,d] = qs.top(); qs.pop();

    if (d > dp[s][min(c,MAX)]) continue;

    for (auto t:graph[s]) {

      if (c-t.c<0) continue;

      if (d+t.d >= dp[t.s][min(c-t.c,MAX)]) continue;

      dp[t.s][min(c-t.c,MAX)] = d+t.d;

      qs.emplace(t.s, c-t.c, d+t.d);

    }

  }

  for (int i = 1; i < n; i++) {

    cout << *min_element(dp[i].begin(), dp[i].end()) << endl;

  }



  return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef vector<ll> vec;

typedef vector<vec> mat;

typedef pair<ll,ll> pll;

const ll mod=1e9+7;

//const ll mod=998244353;

const ll inf=5e18;



struct E{ll to,co,ti;};

struct P{ll ti,id,re;};

bool operator <(const P &a,const P &b) {return a.ti>b.ti;}

ll dp[50][5001],c[50],d[50],ans[50],n,m,s;

vector<E> edge[50];

priority_queue<P> que;



int main() {

  cin >> n >> m >> s;

  for(ll i=0;i<m;i++) {

    ll u,v,a,b;

    cin >> u >> v >> a >> b;

    u--;v--;

    edge[u].push_back({v,a,b});

    edge[v].push_back({u,a,b});

  }

  for(ll i=0;i<n;i++) cin >> c[i] >> d[i];

  que.push({1,0,min(5000LL,s)});

  while(que.size()) {

    P p=que.top();

    que.pop();

    if(dp[p.id][p.re])continue;

    dp[p.id][p.re]=p.ti;

    if(!ans[p.id])ans[p.id]=p.ti;

    for(E q:edge[p.id]) {

      if(p.re>=q.co&&!dp[q.to][p.re-q.co]) {

        que.push({p.ti+q.ti,q.to,p.re-q.co});

      }

    }

    if(p.re+c[p.id]<=5000) que.push({p.ti+d[p.id],p.id,p.re+c[p.id]});

  }

  for(ll i=1;i<n;i++) cout << --ans[i] << endl;

}

// Faster C++ solution for the same problem (measured speedup: 5.758938293983547x):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef vector<ll> vec;

typedef vector<vec> mat;

typedef pair<ll,ll> pll;

const ll mod=1e9+7;

//const ll mod=998244353;

const ll inf=1LL<<61;



typedef pair<ll,pll> ppll;



int main() {

  ll n,m,s;

  cin >> n >> m >> s;

  vector<map<ll,pll>> G(n);

  for(ll i=0;i<m;i++) {

    ll u,v,a,b;

    cin >> u >> v >> a >> b;

    u--,v--;

    G[u][v]={a,b};

    G[v][u]={a,b};

  }

  vec mai(n),mnu(n);

  for(ll i=0;i<n;i++) {

    cin >> mai[i] >> mnu[i];

  }

  mat d(n,vec(50*(n-1)+1,-1));

  vec ans(n,-1);

  vec mins(n,-1);

  priority_queue<ppll,vector<ppll>,greater<ppll>> q;

  s=min(s,50*(n-1));

  q.push({0,{0,s}});

  while(q.size()) {

    ll td=q.top().first;

    ll f=q.top().second.first;

    ll s=q.top().second.second;

    q.pop();

    ll flag=0;

    if(ans[f]<0) ans[f]=td;

    if(d[f][s]>-1) continue;

    d[f][s]=td;

    mins[f]=s;

    for(auto p:G[f]) {

      ll t=p.first;

      ll co=p.second.first;

      ll v=p.second.second;

      if(s-co>=0&&d[t][s-co]==-1) {

        q.push({td+v,{t,s-co}});

      }

    }

    ll ns=min(s+mai[f],50*(n-1));

    ll nd=td+mnu[f];

    if(d[f][ns]==-1) q.push({nd,{f,ns}});

  }

  for(ll i=1;i<n;i++) {

    cout << ans[i] << endl;

  }

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<ll, ll> P;

#define rep(i,n) for (ll i = 0; i < (n); ++i)

#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl

#define mcout(m) rep(j,m.size()){vcout(m[j]);}

const ll MOD = 1e9 + 7;



struct Info{ll v; ll c; ll t;};

struct DP{ll v; ll c; ll t;};



int mainsolve(){



	ll n,m,s;

	cin >> n >> m >> s;

	vector<ll> a(m), b(m);

	vector<vector<Info>> to(n);

	rep(i,m){

		ll u,v;

		cin >> u >> v >> a[i] >> b[i];

		--u; --v;

		to[u].push_back(Info{v,a[i],b[i]});

		to[v].push_back(Info{u,a[i],b[i]});

	}

	vector<ll> c(n), d(n);

	rep(i,n) cin >> c[i] >> d[i];



	ll INF = 1e18;

	ll maxc = n*50; // 銀貨の枚数はこれだけあれば十分

	vector<vector<ll>> dp(n,vector<ll>(maxc,INF)); // dp[v][c]: 銀貨c枚持ってvにいる状態にするためにかかる時間 



	queue<DP> q;

	q.push(DP{0,min(maxc-1,s),0});



	while(!q.empty()){

		DP now = q.front(); q.pop();

		if(now.c >= 0 && now.t >= 0 && now.t < dp[now.v][min(maxc-1,now.c)] ){

			dp[now.v][min(maxc-1,now.c)] = now.t;



			for(Info next : to[now.v]){

				q.push(DP{next.v,now.c - next.c, now.t + next.t}); // 移動

			}

			q.push(DP{now.v,now.c + c[now.v], now.t + d[now.v]}); // 換金

		}

	}



	rep(i,n){

		if(i==0) continue;

		ll res = INF;

		rep(j,maxc) res = min(res, dp[i][j]);

		cout << res << endl;

	}

	

	return 0;

}



int main(){



	return mainsolve();

}

// Faster C++ solution for the same problem (measured speedup: 3.8451478121801346x):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<ll, ll> P;

#define rep(i,n) for (ll i = 0; i < (n); ++i)

#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl

#define mcout(m) rep(j,m.size()){vcout(m[j]);}

const ll MOD = 1e9 + 7;



struct Info{ll v; ll c; ll t;};

struct DP{

	ll v; ll c; ll t;

	bool operator<(const DP& o) const{

		return t > o.t;

	}

};



int mainsolve(){



	ll n,m,s;

	cin >> n >> m >> s;

	vector<ll> a(m), b(m);

	vector<vector<Info>> to(n);

	rep(i,m){

		ll u,v;

		cin >> u >> v >> a[i] >> b[i];

		--u; --v;

		to[u].push_back(Info{v,a[i],b[i]});

		to[v].push_back(Info{u,a[i],b[i]});

	}

	vector<ll> c(n), d(n);

	rep(i,n) cin >> c[i] >> d[i];



	ll INF = 1e18;

	ll maxc = n*50; // 銀貨の枚数はこれだけあれば十分

	vector<vector<ll>> dp(n,vector<ll>(maxc,INF)); // dp[v][c]: 銀貨c枚持ってvにいる状態にするためにかかる時間 



	priority_queue<DP> q;

	q.push(DP{0,min(maxc-1,s),0});



	while(!q.empty()){

		DP now = q.top(); q.pop();

		if(now.c >= 0 && now.t >= 0 && now.t < dp[now.v][min(maxc-1,now.c)] ){

			dp[now.v][min(maxc-1,now.c)] = now.t;



			for(Info next : to[now.v]){

				q.push(DP{next.v,now.c - next.c, now.t + next.t}); // 移動

			}

			q.push(DP{now.v,now.c + c[now.v], now.t + d[now.v]}); // 換金

		}

	}

	

	rep(i,n){

		if(i==0) continue;

		ll res = INF;

		rep(j,maxc) res = min(res, dp[i][j]);

		cout << res << endl;

	}

	

	return 0;

}



int main(){



	return mainsolve();

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<ll, ll> P;

#define rep(i,n) for (ll i = 0; i < (n); ++i)

#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl

#define mcout(m) rep(j,m.size()){vcout(m[j]);}

const ll MOD = 1e9 + 7;



struct Info{ll v; ll c; ll t;};

struct DP{ll v; ll c; ll t;};



int mainsolve(){



	ll n,m,s;

	cin >> n >> m >> s;

	vector<ll> a(m), b(m);

	vector<vector<Info>> to(n);

	rep(i,m){

		ll u,v;

		cin >> u >> v >> a[i] >> b[i];

		--u; --v;

		to[u].push_back(Info{v,a[i],b[i]});

		to[v].push_back(Info{u,a[i],b[i]});

	}

	vector<ll> c(n), d(n);

	rep(i,n) cin >> c[i] >> d[i];



	ll INF = 1e18;

	ll maxc = n*50; // 銀貨の枚数はこれだけあれば十分

	vector<vector<ll>> dp(n,vector<ll>(maxc,INF)); // dp[v][c]: 銀貨c枚持ってvにいる状態にするためにかかる時間 



	queue<DP> q;

	q.push(DP{0,min(maxc-1,s),0});



	while(!q.empty()){

		DP now = q.front(); q.pop();

		if(now.c >= 0 && now.t >= 0 && now.t < dp[now.v][min(maxc-1,now.c)] ){

			dp[now.v][min(maxc-1,now.c)] = now.t;



			for(Info next : to[now.v]){

				q.push(DP{next.v,now.c - next.c, now.t + next.t}); // 移動

			}

			q.push(DP{now.v,now.c + c[now.v], now.t + d[now.v]}); // 換金

		}

	}



	rep(i,n){

		if(i==0) continue;

		ll res = INF;

		rep(j,maxc) res = min(res, dp[i][j]);

		cout << res << endl;

	}

	

	return 0;

}



int main(){



	return mainsolve();

}

// Faster C++ solution for the same problem (measured speedup: 3.8451478121801346x):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<ll, ll> P;

#define rep(i,n) for (ll i = 0; i < (n); ++i)

#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl

#define mcout(m) rep(j,m.size()){vcout(m[j]);}

const ll MOD = 1e9 + 7;



struct Info{ll v; ll c; ll t;};

struct DP{

	ll v; ll c; ll t;

	bool operator<(const DP& o) const{

		return t > o.t;

	}

};



int mainsolve(){



	ll n,m,s;

	cin >> n >> m >> s;

	vector<ll> a(m), b(m);

	vector<vector<Info>> to(n);

	rep(i,m){

		ll u,v;

		cin >> u >> v >> a[i] >> b[i];

		--u; --v;

		to[u].push_back(Info{v,a[i],b[i]});

		to[v].push_back(Info{u,a[i],b[i]});

	}

	vector<ll> c(n), d(n);

	rep(i,n) cin >> c[i] >> d[i];



	ll INF = 1e18;

	ll maxc = n*50; // 銀貨の枚数はこれだけあれば十分

	vector<vector<ll>> dp(n,vector<ll>(maxc,INF)); // dp[v][c]: 銀貨c枚持ってvにいる状態にするためにかかる時間 



	priority_queue<DP> q;

	q.push(DP{0,min(maxc-1,s),0});



	while(!q.empty()){

		DP now = q.top(); q.pop();

		if(now.c >= 0 && now.t >= 0 && now.t < dp[now.v][min(maxc-1,now.c)] ){

			dp[now.v][min(maxc-1,now.c)] = now.t;



			for(Info next : to[now.v]){

				q.emplace(DP{next.v,now.c - next.c, now.t + next.t}); // 移動

			}

			q.emplace(DP{now.v,now.c + c[now.v], now.t + d[now.v]}); // 換金

		}

	}

	

	rep(i,n){

		if(i==0) continue;

		ll res = INF;

		rep(j,maxc) res = min(res, dp[i][j]);

		cout << res << endl;

	}

	

	return 0;

}



int main(){



	return mainsolve();

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<ll, ll> P;

#define rep(i,n) for (ll i = 0; i < (n); ++i)

#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl

#define mcout(m) rep(j,m.size()){vcout(m[j]);}

const ll MOD = 1e9 + 7;



struct Info{ll v; ll c; ll t;};

struct DP{ll v; ll c; ll t;};



int mainsolve(){



	ll n,m,s;

	cin >> n >> m >> s;

	vector<ll> a(m), b(m);

	vector<vector<Info>> to(n);

	rep(i,m){

		ll u,v;

		cin >> u >> v >> a[i] >> b[i];

		--u; --v;

		to[u].push_back(Info{v,a[i],b[i]});

		to[v].push_back(Info{u,a[i],b[i]});

	}

	vector<ll> c(n), d(n);

	rep(i,n) cin >> c[i] >> d[i];



	ll INF = 1e18;

	ll maxc = n*50; // 銀貨の枚数はこれだけあれば十分

	vector<vector<ll>> dp(n,vector<ll>(maxc,INF)); // dp[v][c]: 銀貨c枚持ってvにいる状態にするためにかかる時間 



	queue<DP> q;

	q.push(DP{0,min(maxc-1,s),0});



	while(!q.empty()){

		DP now = q.front(); q.pop();

		if(now.c >= 0 && now.t >= 0 && now.t < dp[now.v][min(maxc-1,now.c)] ){

			dp[now.v][min(maxc-1,now.c)] = now.t;



			for(Info next : to[now.v]){

				q.push(DP{next.v,now.c - next.c, now.t + next.t}); // 移動

			}

			q.push(DP{now.v,now.c + c[now.v], now.t + d[now.v]}); // 換金

		}

	}



	rep(i,n){

		if(i==0) continue;

		ll res = INF;

		rep(j,maxc) res = min(res, dp[i][j]);

		cout << res << endl;

	}

	

	return 0;

}



int main(){



	return mainsolve();

}

// Faster C++ solution for the same problem (measured speedup: 3.8508054532776836x):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<ll, ll> P;

#define rep(i,n) for (ll i = 0; i < (n); ++i)

#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl

#define mcout(m) rep(j,m.size()){vcout(m[j]);}

const ll MOD = 1e9 + 7;



struct Info{ll v; ll c; ll t;};

struct DP{

	ll v; ll c; ll t;

	bool operator<(const DP& o) const{

		return t > o.t;

	}

};



int mainsolve(){



	ll n,m,s;

	cin >> n >> m >> s;

	vector<ll> a(m), b(m);

	vector<vector<Info>> to(n);

	rep(i,m){

		ll u,v;

		cin >> u >> v >> a[i] >> b[i];

		--u; --v;

		to[u].push_back(Info{v,a[i],b[i]});

		to[v].push_back(Info{u,a[i],b[i]});

	}

	vector<ll> c(n), d(n);

	rep(i,n) cin >> c[i] >> d[i];



	ll INF = 1e18;

	ll maxc = n*50; // 銀貨の枚数はこれだけあれば十分

	vector<vector<ll>> dp(n,vector<ll>(maxc,INF)); // dp[v][c]: 銀貨c枚持ってvにいる状態にするためにかかる時間 



	priority_queue<DP> q;

	q.push(DP{0,min(maxc-1,s),0});



	while(!q.empty()){

		DP now = q.top(); q.pop();

		if(now.c >= 0 && now.t >= 0 && now.t < dp[now.v][min(maxc-1,now.c)] ){

			dp[now.v][min(maxc-1,now.c)] = now.t;

q.emplace(DP{now.v,now.c + c[now.v], now.t + d[now.v]}); // 換金

			for(Info next : to[now.v]){

				q.emplace(DP{next.v,now.c - next.c, now.t + next.t}); // 移動

			}

			

		}

	}

	

	rep(i,n){

		if(i==0) continue;

		ll res = INF;

		rep(j,maxc) res = min(res, dp[i][j]);

		cout << res << endl;

	}

	

	return 0;

}



int main(){



	return mainsolve();

}
// Slower C++ solution:
#include<iostream>

using namespace std;

int t[10][10],u[10][10],ans[10][10],n,flg;

int compute();

void dfs(int);

void change(int,int);

int main(){

  cin>>n;

  while(n--){

    flg=0;

    for(int i=0;i<10;i++){

      for(int j=0;j<10;j++){

	cin>>t[i][j];

	ans[i][j]=0;

      }

    }

    dfs(0);

  }

  return 0;

}

void dfs(int x){

  if(x==10){

    /*

    for(int i=0;i<10;i++)cout<<ans[0][i];

    cout<<endl;

    */

    

    if(compute()){

      for(int i=0;i<10;i++){

	for(int j=0;j<10;j++){

	  if(j)cout<<' ';

	  cout<<ans[i][j];

	}

	cout<<endl;

      }

    }

    

    return;

  }

  ans[0][x]=0;

  dfs(x+1);

  ans[0][x]=1;

  dfs(x+1);

}



int compute(){

  for(int i=0;i<10;i++){

    for(int j=0;j<10;j++){

      u[i][j]=t[i][j];

      if(i)ans[i][j]=0;

    }

  }



  for(int i=0;i<10;i++){

    if(ans[0][i])change(0,i);

  }



  for(int i=1;i<10;i++){

    for(int j=0;j<10;j++){

      if(u[i-1][j]){

	ans[i][j]=1;

	change(i,j);

      }

    }

  }

  for(int i=0;i<10;i++){

    if(u[9][i])return 0;

  }

  return 1;

}



void change(int y,int x){

  u[y][x]=!u[y][x];

  if(y>0)u[y-1][x]=!u[y-1][x];

  if(x>0)u[y][x-1]=!u[y][x-1];

  if(y<9)u[y+1][x]=!u[y+1][x];

  if(x<9)u[y][x+1]=!u[y][x+1];

}

// Faster C++ solution for the same problem (measured speedup: 1.3737488311226758x):
#include<iostream>

using namespace std;

int I,flg;

int t[10][10],u[10][10];

int ans[10][10];

void check();

void dfs(int);

void compute(int,int);

int main(){

  cin>>I;

  while(I--){

    flg=0;

    for(int i=0;i<10;i++){

      for(int j=0;j<10;j++){

	cin>>t[i][j];

	u[i][j]=t[i][j];

	ans[i][j]=0;

      }

    }

    dfs(0);

  }

  return 0;

}





void dfs(int x){

  if(flg)return;

  if(x==10){

    check();

  }else{

    ans[0][x]=0;

    dfs(x+1);

    if(flg)return;

    ans[0][x]=1;

    dfs(x+1);

  }

}





void check(){

  if(flg)return;

  for(int i=0;i<10;i++)for(int j=0;j<10;j++)t[i][j]=u[i][j];



  for(int i=0;i<10;i++)if(ans[0][i]==1)compute(0,i);

  

  for(int i=1;i<10;i++){

    for(int j=0;j<10;j++){

      ans[i][j]=0;

      if(t[i-1][j]==1){

	ans[i][j]=1;

	compute(i,j);

      }

    }

  }

  /*

  for(int i=0;i<10;i++){

    for(int j=0;j<10;j++){

      if(j)cout<<' ';

      cout<<t[i][j];

    }

    cout<<endl;

  }

  */

  int cnt=0;

  for(int i=0;i<10;i++)cnt+=t[9][i];

  if(cnt==0){

    flg=1;

    for(int i=0;i<10;i++){

      for(int j=0;j<10;j++){

	if(j)cout<<' ';

	cout<<ans[i][j];

      }

      cout<<endl;

    }

  }

}



void compute(int y,int x){

  t[y][x]=(t[y][x]*-1)+1;

  if(y>0)t[y-1][x]=(t[y-1][x]*-1)+1;

  if(x>0)t[y][x-1]=(t[y][x-1]*-1)+1;

  if(y<9)t[y+1][x]=(t[y+1][x]*-1)+1;

  if(x<9)t[y][x+1]=(t[y][x+1]*-1)+1;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

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

#define rep1(i, n) for(int i = 1; i <= (n); i++)

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define pb push_back

#define mp make_pair

#define Would

#define you

#define please





int main() {

	cin.tie(0);

	ios::sync_with_stdio(false);





	int N;

	cin >> N;

	ll a[100000];

	ll goukei = 0;

	rep(i, N) {

		cin >> a[i];

		goukei ^= a[i];

	}



	int M = 60;

	bool A[100000][60] = {};

	rep(i, N) {

		rep(j, M) {

			A[i][j] = a[i] >> j & 1;

		}

	}



	int r = 0;

	for (int i = M - 1; i >= 0; i--) {

		if (!(goukei >> i & 1)) {

			for (int j = r; j < N; j++) {

				if (A[j][i]) {

					rep(k, M) swap(A[r][k], A[j][k]);



					for (int j = r + 1; j < N; j++) {

						if (A[j][i]) {

							rep(k, M) A[j][k] ^= A[r][k];

						}

					}

					if (!A[0][i]) {

						rep(k, M) A[0][k] ^= A[r][k];

					}

					r++;

					break;

				}

			}

		}

	}



	ll kotae = 0;

	rep(i, M) {

		if (!(goukei >> i & 1)) {

			if (A[0][i]) {

				kotae += 1ll << (i + 1);

			}

		}

		else {

			kotae += 1ll << i;

		}

	}

	co(kotae);







	Would you please return 0;

}

// Faster C++ solution for the same problem (measured speedup: 7.170280543233984x):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

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

#define rep1(i, n) for(int i = 1; i <= (n); i++)

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define pb push_back

#define mp make_pair

#define Would

#define you

#define please





int main() {

	cin.tie(0);

	ios::sync_with_stdio(false);





	int N;

	cin >> N;

	ll a[100000];

	ll goukei = 0;

	rep(i, N) {

		cin >> a[i];

		goukei ^= a[i];

	}



	int M = 60;

	int r = 0;

	for (int i = M - 1; i >= 0; i--) {

		if (!(goukei >> i & 1)) {

			for (int j = r; j < N; j++) {

				if (a[j] >> i & 1) {

					swap(a[r], a[j]);



					for (int j = r + 1; j < N; j++) {

						if (a[j] >> i & 1) {

							a[j] ^= a[r];

						}

					}

					if (!(a[0] >> i & 1)) {

						a[0] ^= a[r];

					}

					r++;

					break;

				}

			}

		}

	}



	co(a[0] + (a[0] ^ goukei));



	Would you please return 0;

}