#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

struct rolling_hash{
    // !!! ハッシュはullで受け取ること !!!
    typedef unsigned int ui;
    typedef unsigned long long ull;

    const ull MASK30 = (1ull<<30) - 1;
    const ull MASK31 = (1ull<<31) - 1;
    const ull MOD = (1ull<<61) - 1;
    const ull POSITIVISER = MOD * ((1ull<<3) - 1);
    ui base;
    int n;
    vector<ull> pw, hs;

    rolling_hash(){}

    rolling_hash(const vector<ll> &s, int bs){
        // set base
        base = (ui)bs;
        
        n = s.size();
        hs.assign(n+1, 0);
        pw.assign(n+1, 0);
        hs[0] = 0;
        pw[0] = 1;
        for(int i=0;i<n;i++){
            pw[i+1] = calc_mod(mul(pw[i], base));
            hs[i+1] = calc_mod(mul(hs[i], base) + s[i]); 
        }
    }

    ull hash(int l, int r){
        return calc_mod(hs[r] + POSITIVISER - mul(hs[l], pw[r-l]));
    }

    ull mul(ull l, ull r){
        ull lu = l>>31;
        ull ld = l & MASK31;
        ull ru = r>>31;
        ull rd = r & MASK31;
        ull middle_bit = ld * ru + lu * rd;
        return ((lu*ru)<<1) +ld*rd + ((middle_bit & MASK30) << 31) + (middle_bit>>30);
    }

    ull mul(ull l, ui r){
        ull lu = l>>31;
        ull rd = r & MASK31;
        ull middle_bit = lu * rd;
        return (l & MASK31) * rd + ((middle_bit & MASK30)<<31) + (middle_bit>>30);
    }

    ull calc_mod(ull val){
        val = (val & MOD) + (val>>61);
        if(val > MOD) val -= MOD;
        return val;
    }
};

int generate_base(){
    random_device seed_gen;
    mt19937_64 rnd(seed_gen());
    uniform_int_distribution<int> dist(129, INT_MAX);
    int base = dist(rnd);
    return base;
}

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

    ll N;
    cin >> N;
    vector<ll> a(N), b(N);
    REP(i, N) cin >> a[i];
    REP(i, N) cin >> b[i];

    vector<ll> c(N), d(N);
    REP(i, N) c[i] = (a[i]^a[(i+1)%N]);
    REP(i, N) d[i] = (b[i]^b[(i+1)%N]);

    int base = generate_base();
    rolling_hash rc(c, base), rd(d, base);
    vector<pll> res;
    REP(i, N){
        bool ok = true;
        /*
        REP(j, 2){
            if(rc.hash(i, N, j) != rd.hash(0, N-i, j) || rc.hash(0, i, j) != rd.hash(N-i, N, j)) ok =false;
        }
        */
        if(rc.hash(i, N) != rd.hash(0, N-i) || rc.hash(0, i) != rd.hash(N-i, N)) ok = false;
        if(ok){
            //cout << N-i << " " << (a[N-i]^b[0]) << endl;
            res.push_back({i, a[i]^b[0]});
        }
    }
    sort(res.begin(), res.end());
    REP(i, res.size()){
        cout << res[i].first << " " << res[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 20204