#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using u64 = uint_fast64_t; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
////////////////////////////////////////////////////////////////////////

template <typename S>
struct RollingHash {
private:
    static const u64 mod = (1ull << 61) - 1;
    const u64 MASK30 = (1ull << 30) - 1;
    const u64 MASK31 = (1ull << 31) - 1;
    const u64 POSITIVIZER = mod * ((1ull << 3) - 1);
    u64 base;
    vector<u64> power;

    u64 Mul (u64 a, u64 b) {
        u64 au = a >> 31;
        u64 ad = a & MASK31;
        u64 bu = b >> 31;
        u64 bd = b & MASK31;
        u64 mid = ad * bu + au * bd;
        u64 midu = mid >> 30;
        u64 midd = mid & MASK30;
        return (au * bu * 2 + midu + (midd << 31) + ad * bd);
    }

    u64 CalcMod(u64 val) {
        val = (val & mod) + (val >> 61);
        if (val >= mod) val -= mod;
        return val;
    }

public:
    static inline u64 generate_base() {
        mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
        uniform_int_distribution<u64> rand(1, RollingHash::mod - 1);
        return rand(mt);
    }

    RollingHash(int N, u64 base) : power(N+1,1), base(base) {
        for (int i = 0; i < N; ++i) {
            power[i+1] = CalcMod(Mul(power[i],base));
        }
    }

    vector<u64> gethash(const S &s) {
        int sz = s.size();
        vector<u64> ret(sz+1);
        for (int i = 0; i < sz; ++i) {
            ret[i+1] = CalcMod(Mul(ret[i],base) + s[i] + 1);
        }
        return ret;
    }

    // [l,r) (0-indexed)
    u64 getrange(const vector<u64> &hash, int l, int r) {
        return CalcMod(hash[r] + POSITIVIZER - Mul(hash[l],power[r-l]));
    }

    u64 getval(const S &s) {
        u64 ret = 0;
        for (int i = 0; i < s.size(); ++i) {
            ret = CalcMod(Mul(ret,base) + s[i] + 1);
        }
        return ret;
    }

    u64 connect(u64 hl, u64 hr, int rlen) {
        return CalcMod(CalcMod(Mul(hl,power[rlen])) + hr);
    }

	int LCP(const vector<u64> &a, const vector<u64> &b, int l1, int r1, 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 (getrange(a, l1, l1 + mid) == getrange(b, l2, l2 + mid)) low = mid;
      		else high = mid;
    	}
    	return low;
	}
};


/////////////////////////////////////////////////////////////////////////////////

void ALDS1_14_B() {
	string T,P; cin >> T >> P;
    int N = T.size();
    int M = P.size();

    auto base = RollingHash<string>::generate_base();
    RollingHash<string> rh(max(N,M),base);
    auto rht = rh.gethash(T);
    auto p = rh.getval(P);
    rep(i,N-M+1) {
        if (rh.getrange(rht,i,i+M)==p) {
            cout << i << ln;
        }
    }
}

void abc150_f() {
    int N; cin >> N;
    vector<ll> A(N),B(N);
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> B[i];

    vector<ll> P(2*N),Q(N);
    rep(i,2*N) P[i] = A[i%N]^A[(i+1)%N];
    rep(i,N) Q[i] = B[i%N]^B[(i+1)%N];

    using RH = RollingHash<vector<ll>>;
    auto base = RH::generate_base();
    RH rh(2*N,base);

    auto rhp = rh.gethash(P);
    auto q = rh.getval(Q);
    rep(i,N) {
        if (rh.getrange(rhp,i,i+N)==q) {
            cout << i << " " << (A[i]^B[0]) << ln;
        }
    }
}

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
    //ALDS1_14_B();
    abc150_f();
}

/*
  verified on 2020/05/26
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_14_B&lang=jp
  https://atcoder.jp/contests/abc150/tasks/abc150_f
*/

Measured memory_bytes: 17536