#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


template<unsigned MOD>
struct RollingHash{
  //hashed: hashed[0]=0でhashed[i+1]=0~iのハッシュ値
  //hashed[k]=Σ[i=0 to k]s[i]*base^(k-i-1)
  vector<unsigned> hashed,power;
  //↓????
  inline unsigned mul(unsigned a, unsigned b) const{
      unsigned long long x=(unsigned long long) a*b;
      unsigned xh=(unsigned)(x>>32), xl=(unsigned)x,d,m;
      asm("divl %4; \n\t" : "=a" (d), "=d" (m) : "d" (xh), "a" (xl), "r" (MOD));
      return m;
  }
  RollingHash(vector<ll> &s, unsigned base=10007){
      int sz=(int)s.size();
      hashed.assign(sz+1,0);
      power.assign(sz+1,0);
      power[0]=1;
      for(int i=0;i<sz;i++){
          power[i+1]=mul(power[i],base);
          //s[i]の値をそのまま足してるから
          //sが数字になろうがアルファベットだろうがok
          hashed[i+1]=mul(hashed[i],base)+s[i];
          if(hashed[i+1]>=MOD) hashed[i+1]-=MOD;
      }
  }
  //[l,r)のハッシュ値の取得
  //abracadabra
  //hashed[7]           =a*base^6+b*base^5+r*base^4+...+d
  //hashed[3]           =a*base^2+b*base  +r
  //hashed[3]*base^(7-3)=a*base^6+b*base^5+r*base^4
  //引くと[l,r)のハッシュ値が求まる
  unsigned get(int l, int r)const{
      unsigned ret=hashed[r]+MOD-mul(hashed[l],power[r-l]);
      if(ret>=MOD)ret-=MOD;
      return ret;
  }
  // h1,h2はハッシュ値
  unsigned connect(unsigned h1, int h2, int h2len) const{
      unsigned ret=mul(h1,power[h2len])+h2;
      if(ret>=MOD) ret-=MOD;
      return ret;
  }
  //l1,r1 : このハッシュの区間[l1,r1)
  //比較したいハッシュbと，それの区間[l2,r2)
  //返り値はLongestCommonPrefixの長さ
  //単純な文字列の比較ならgetして比べる．O(1)とO(log)違うから
  //logは定数じゃない！(戒め)
  int LCP(int l1, int r1, const RollingHash<MOD> &b, int l2, int r2){
      //ニブタンをする
      int len=min(r1-l1,r2-l2);
      int low=-1,high=len+1;
      while(high-low>1){
          int mid=(low+high)/2;
          if(get(l1,l1+mid)==b.get(l2,l2+mid))    low =mid;
          else                                    high=mid;
      }
      return (low);
  }
};using RH = RollingHash<1000000007>;
#define mod2 1000000033
#define mod3 1000000087
#define base2 1033
#define base3 5051

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);

    int n;cin>>n;
    vector<ll> a(n),b(n);
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    rep(i,n-1)a.push_back(a[i]);
    rep(i,n-1)b.push_back(b[i]);
    vector<ll> A,B;
    rep(i,b.size()-1){
        B.push_back(b[i]^b[i+1]);
    }
    rep(i,n-1){
        A.push_back(a[i]^a[i+1]);
    }
    int m=A.size();
    RollingHash<mod2> AR1(A,base2),BR1(B,base2);
    RollingHash<mod3> AR2(A,base3),BR2(B,base3);
    vector<pair<ll,ll>> ans;
    rep(i,n){
        if(AR1.get(0,m)==BR1.get(i,i+m) and AR2.get(0,m)==BR2.get(i,i+m)){
            ans.push_back(make_pair((n-i)%n,a[0]^b[i]));
        }
    }
    sort(ALL(ans));
    for(auto x:ans){
        cout<<x.first<<' '<<x.second<<endl;
    }
    return 0;
}


Measured memory_bytes: 31300