#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;


template <typename T, int64_t BASE, int64_t MOD> class RollingHash{
private:
  static std::vector<int64_t> pow;

public:
  static void init(int N){
    pow.assign(N+1,0);
    pow[0] = 1;
    for(int i = 1; i <= N; ++i){
      pow[i] = pow[i-1] * BASE % MOD;
    }
  }

  static std::vector<int64_t> generate_hash(const T &s){
    std::vector<int64_t> ret(s.size()+1);

    for(int i = 1; i <= (int)s.size(); ++i){
      ret[i] = (ret[i-1] * BASE + s[i-1]) % MOD;
    }
    
    return ret;
  }

  static int64_t hash(const std::vector<int64_t> &shash, int i, int j){ // [i, j)
    return (shash[j] - shash[i] * pow[j-i] + MOD * MOD) % MOD;
  }

  static int64_t hash(const T &p){
    int64_t phash = 0;
    for(int i = 0; i < (int)p.size(); ++i) phash = (phash * BASE + p[i]) % MOD;
    return phash;
  }

  static std::vector<int> find(const std::vector<int64_t> &shash, const T &p){
    std::vector<int> ret;
    int pl = p.size();
    int64_t phash = hash(p);
    for(int i = 0; i < (int)shash.size()-pl; ++i) if(hash(shash,i,i+pl) == phash) ret.push_back(i);
    return ret;
  }
};

template <typename T, int64_t BASE, int64_t MOD> std::vector<int64_t> RollingHash<T,BASE,MOD>::pow;



int main(){
  using RH = RollingHash<vector<int>, 31, 1000000007>;
  RH::init(200000);
  
  int N;
  while(cin >> N){
    vector<int> a(N), b(N); cin >> a >> b;

    vector<int> A, B;

    REP(i,2*N-2){
      A.push_back(a[i%N] ^ a[(i+1)%N]);
    }
    
    REP(i,N-1){
      B.push_back(b[i] ^ b[i+1]);
    }

    //dump(A, B);

    auto hash_a = RH::generate_hash(A);

    auto pos = RH::find(hash_a, B);

    dump(pos);

    for(auto k : pos){
      int x = b[0] ^ a[k];
      
      cout << k << " " << x << endl;
    }    
  }

  return 0;
}


Measured memory_bytes: 13936