#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void *wmem;
char memarr[96000000];
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S> void arrInsert(const int k, int &sz, S a[], const S aval){
  int i;
  sz++;
  for(i=sz-1;i>k;i--){
    a[i] = a[i-1];
  }
  a[k] = aval;
}
template<class S, class T> void arrInsert(const int k, int &sz, S a[], const S aval, T b[], const T bval){
  int i;
  sz++;
  for(i=sz-1;i>k;i--){
    a[i] = a[i-1];
  }
  for(i=sz-1;i>k;i--){
    b[i] = b[i-1];
  }
  a[k] = aval;
  b[k] = bval;
}
template<class S, class T, class U> void arrInsert(const int k, int &sz, S a[], const S aval, T b[], const T bval, U c[], const U cval){
  int i;
  sz++;
  for(i=sz-1;i>k;i--){
    a[i] = a[i-1];
  }
  for(i=sz-1;i>k;i--){
    b[i] = b[i-1];
  }
  for(i=sz-1;i>k;i--){
    c[i] = c[i-1];
  }
  a[k] = aval;
  b[k] = bval;
  c[k] = cval;
}
template<class T, class S> int KMP(T A[], int As, T B[], int Bs, S res[] = NULL, int *fail = (int*)wmem){
  int i;
  int k;
  int cnt = 0;
  k = fail[0] = -1;
  for(i=(0);i<(Bs);i++){
    while(k>=0 && B[k]!=B[i]){
      k = fail[k];
    }
    fail[i+1] = ++k;
  }
  if(res != NULL){
    for(i=(0);i<(As);i++){
      res[i] = 0;
    }
  }
  k = 0;
  for(i=(0);i<(As);i++){
    while(k >= 0 && B[k] != A[i]){
      k = fail[k];
    }
    k++;
    if(k == Bs){
      cnt++;
      if(res != NULL){
        res[i-Bs+1] = 1;
      }
      k = fail[k];
    }
  }
  return cnt;
}
int N;
int A[200000];
int B[200000];
int aa[400000];
int bb[400000];
int ok[400000];
int ress;
int res1[200000];
int res2[200000];
int main(){
  int i;
  wmem = memarr;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  {
    int e98WHCEY;
    for(e98WHCEY=(0);e98WHCEY<(N);e98WHCEY++){
      rd(B[e98WHCEY]);
    }
  }
  for(i=(0);i<(2*N);i++){
    aa[i] = A[(i+1)%N] ^ A[i%N];
  }
  for(i=(0);i<(N);i++){
    bb[i] = B[(i+1)%N] ^ B[i%N];
  }
  KMP(aa,2*N,bb,N,ok);
  for(i=(0);i<(N);i++){
    if(ok[i]){
      arrInsert(ress,ress,res1,i,res2,A[i]^B[0]);
    }
  }
  for(i=(0);i<(ress);i++){
    wt_L(res1[i]);
    wt_L(' ');
    wt_L(res2[i]);
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20191229-1 [beta]

// --- original code ---
// int N, A[2d5], B[2d5];
// int aa[4d5], bb[4d5];
// int ok[4d5];
// 
// int ress, res1[2d5], res2[2d5];
// 
// {
//   rd(N,A(N),B(N));
//   rep(i,2N) aa[i] = A[(i+1)%N] ^ A[i%N];
//   rep(i, N) bb[i] = B[(i+1)%N] ^ B[i%N];
// 
//   KMP(aa,2N,bb,N,ok);
//   rep(i,N) if(ok[i]) arrInsert(ress,ress,res1,i,res2,A[i]^B[0]);
// 
//   rep(i,ress) wt(res1[i], res2[i]);
// }


Measured memory_bytes: 13696