#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
long double pi=3.14159265358979323846L;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll gya[1000010];
ll kai[1000010];
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll n;cin>>n;
    ll a[n],b[n];
    ll naa[30],nab[30],nba[30],nbb[30];
    fill(naa,naa+30,0);
    fill(nab,nab+30,0);
    fill(nbb,nbb+30,0);
    fill(nba,nba+30,0);
    ll ba=1,bb=1;
    ll m1=1000000007,m2=1000000009;
    vector<ll> va[30],vab[30],vbb[30],vb[30];
    rep(i,0,n){
        cin>>a[i];
        ll y=a[i];
        rep(j,0,30){
            naa[j]*=10007;
            naa[j]+=(y%2);
            naa[j]%=m1;
            
            nab[j]*=10009;
            nab[j]+=(y%2)^1;
            nab[j]%=m2;
            va[j].push_back(y%2);
            y/=2;
        }
        
    }
    ba=1;
    bb=1;
    rep(i,0,n){
        cin>>b[i];
        ll y=b[i];
        rep(j,0,30){
            nba[j]*=10007;
            nba[j]+=(y%2);
            nba[j]%=m1;
            
            nbb[j]*=10009;
            nbb[j]+=(y%2);
            nbb[j]%=m2;
            y/=2;
            vb[j].push_back(y%2);
        }
        ba*=10007;
        ba%=m1;
        bb*=10009;
        bb%=m2;
    }
    //cout<<naa[0]<<" "<<nba[0]<<endl;
    bool ok[n];
    fill(ok,ok+n,true);
    ba=beki(10007,n-1,m1);
    bb=beki(10009,n-1,m2);
    vector<ll> ans;
    rep(i,0,n){
        int r=0;
        rep(j,0,30){
            if(naa[j]!=nba[j]&&nab[j]!=nbb[j]){
                r=1;
            }
            naa[j]+=-va[j][i]*ba+m1;
            naa[j]%=m1;
            nab[j]+=-(va[j][i]^1)*bb+m2;
            nab[j]%=m2;
            naa[j]*=10007;
            naa[j]%=m1;
            nab[j]*=10009;
            nab[j]%=m2;
            naa[j]+=va[j][i];
            nab[j]+=(va[j][i]^1);
            naa[j]%=m1;
            nab[j]%=m2;
        }
        if(r==0){
            ans.push_back(i);
        }
    }
    
    rep(i,0,ans.size()){
        ll num=b[0]^a[ans[i]];
        cout<<ans[i]<<" "<<num<<endl;
    }
}


Measured memory_bytes: 112552