#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1000000007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }
class RollingHash{
    int N;
    unsigned long long base;
    const unsigned long long MOD0 = 1000000007;
    const unsigned long long MOD1 = 1000000009;
    vector<unsigned long long> pow0, pow1;
    vector<unsigned long long> hash_cum0, hash_cum1;
public:
    RollingHash(unsigned long long base=10007) : base(base) {};
    void set(vector<unsigned long long> v){
        N = v.size();

        pow0.resize(N+1);
        pow1.resize(N+1);
        hash_cum0.resize(N+1);
        hash_cum1.resize(N+1);

        pow0[0] = pow1[0] = 1;
        hash_cum0[0] = hash_cum0[0] = 0;

        for(int i=1; i<=N; i++){
            pow0[i] = (pow0[i-1] * base) % MOD0;
            pow1[i] = (pow1[i-1] * base) % MOD1;
        }

        for(int i=1; i<=N; i++){
            hash_cum0[i] = ((base * hash_cum0[i-1]) % MOD0 + v[i-1]) % MOD0;
            hash_cum1[i] = ((base * hash_cum1[i-1]) % MOD1 + v[i-1]) % MOD1;
        }
    }
    // [l, r) のハッシュ値を取得
    pair<unsigned long long, unsigned long long> get(int l, int r){
        unsigned long long hash0 = (hash_cum0[r] + MOD0 - (hash_cum0[l] * pow0[r-l]) % MOD0) % MOD0;
        unsigned long long hash1 = (hash_cum1[r] + MOD1 - (hash_cum1[l] * pow1[r-l]) % MOD1) % MOD1;
        return make_pair(hash0, hash1);
    }
    // 引数で与えられる v のハッシュ値を取得
    pair<unsigned long long, unsigned long long> get(const vector<unsigned long long> &v){
        unsigned long long hash0 = 0;
        unsigned long long hash1 = 0;
        for(int i=0; i<v.size(); i++){
            hash0 = ((base * hash0) % MOD0 + v[i]) % MOD0;
            hash1 = ((base * hash1) % MOD1 + v[i]) % MOD1;
        }
        return make_pair(hash0, hash1);
    }
    // set されている列 v に対して、v[i,:], v[j,:] の LCP 長さを取得する
    int lcp(int i, int j){
        int l = 0;
        int r = min(N-i, N-j)+1;
        while(r - l > 1){
            int m = (l + r) / 2;
            if(get(i, i + m) == get(j, j + m)) l = m;
            else                               r = m;
        }
        return l;
    }
};

int main(){
    int N;
    cin >> N;
    vector<unsigned long long> a(N), b(N);
    REP(i, N) cin >> a[i];
    REP(i, N) cin >> b[i];

    vector<unsigned long long> 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];

    vector<unsigned long long> cc(2*N);
    REP(i, N) cc[i] = cc[N+i] = c[i];
    RollingHash rh;
    auto hashB = rh.get(d);
    rh.set(cc);
    vector<int> ks;
    for(int k=0; k<N; k++){
        auto hashA = rh.get(k, k+N);
        if(hashA == hashB){
            ks.push_back(k);
        }
    }
    for(auto k : ks){
        unsigned long long x = a[k] ^ b[0];
        cout << k << " " << x << endl;
    }
    return 0;
}

Measured memory_bytes: 27208