#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

vector<int> Z_algorithm(vector<ll> S) {
	int c = 0, n = S.size();
	vector<int> Z(n, 0);
	for (int i = 1; i < n; i++) {
		int l = i - c;
		if (i + Z[l] < c + Z[c]) {
			Z[i] = Z[l];
		} else {
			int j = max(0, c + Z[c] - i);
			while (i + j < n && S[j] == S[i + j])j++;			
			Z[i] = j;
			c = i;
		}
	}
	Z[0] = n;
	return Z;
}

int main(){
  int n;
  cin >> n;
  vector<ll> a(mx), b(mx);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  
  vector<ll> axor(n),bxor(n);
  rep(i,n){ axor[i]=a[i]^a[i+1]; } axor[n-1]=a[n-1]^a[0]; 
  rep(i,n){ bxor[i]=b[i]^b[i+1]; } bxor[n-1]=b[n-1]^b[0]; 
  auto tmp = bxor;
  rep(j,2)rep(i,n) tmp.emplace_back(axor[i]);

  vector<pair<int,ll>> kx;
  auto res = Z_algorithm(tmp);
  for(int i=n; i<n*2; i++)if(res[i]>=n){
    kx.push_back({i-n,b[0]^a[i-n]});
  }

  sort(kx.begin(),kx.end());
  for(auto ans:kx){
    cout << ans.F << " " << ans.S << endl;
  }
  return 0;
}

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <set> 
# include <map>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    ll n; cin>>n;
    vector<ll> v(n);
    REP(i,n)cin>>v[i];
    sort(ALL(v));
    vector<ll> sides;
    vector<ll> list;
    map<ll,ll> mp;
    REP(i,n){
        ll a=v[i];
        if(mp.find(a)!=mp.end()){
            mp.at(a)++;
            list.push_back(a);
        }else{
            mp.insert(make_pair(a,1));
        }
    }
    REP(i,SIZE(list)){
        ll s=list[i];
        while(mp.at(s)/=2){
            sides.push_back(s);
        }
    }
    ll ans;
    if(SIZE(sides)<2){
        ans=0;
    }else{
        sort(ALL(sides),greater<>());
        ans=sides[0]*sides[1];
    }
    cout<<ans<<endl;
    return 0;
}
