#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned 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 MASK30 = (1ull << 30) - 1;
    static const u64 MASK31 = (1ull << 31) - 1;
    static const u64 mod = (1ull << 61) - 1;
    static const u64 POSITIVIZER = mod * ((1ull << 3) - 1);

    static 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);
    }

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

    vector<u64> hash,power;

public:
    static u64 &base() {static u64 base = 0; return base;}
    static void set (u64 b) {base() = b;}

    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(const S &s) {
        int sz = s.size();
        hash.assign(sz + 1,0);
        power.assign(sz + 1,1);
        for (int i = 0; i < sz; i++) {
            power[i+1] = CalcMod(Mul(power[i],base()));
            hash[i+1] = CalcMod(Mul(hash[i],base()) + s[i] + 1);
        }
    }

    u64 get(int l, int r) { // [l,r) (0-indexed)
        u64 ret;
        ret = CalcMod(hash[r] + POSITIVIZER - Mul(hash[l],power[r-l]));
        return ret;
    }

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

	int LCP(RollingHash &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(get(l1, l1 + mid) == b.get(l2, l2 + mid)) low = mid;
      		else high = mid;
    	}
    	return (low);
	}
};

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

void ALDS1_14_B() {
    const ull base = RollingHash<string>::generate_base();
    RollingHash<string>::set(base);

	string T,P; cin >> T >> P;
    int N = T.size();
    int M = P.size();
    RollingHash<string> rh(T);
    auto p = RollingHash<string>::gethash(P);
    rep(i,N-M+1) {
        if (rh.get(i,i+M)==p) {
            cout << i << ln;
        }
    }
}

void abc150() {
    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];

    auto base = RollingHash<vector<ll>>::generate_base();
    RollingHash<vector<ll>>::set(base);
    RollingHash<vector<ll>> rh(P);

    auto b = RollingHash<vector<ll>>::gethash(Q);
    rep(i,N) {
        if (rh.get(i,i+N)==b) {
            cout << i << " " << (A[i]^B[0]) << ln;
        }
    }
}

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

/*
  verified on 2020/02/18
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_14_B&lang=jp
  https://atcoder.jp/contests/abc150/submissions/10188067
*/

Measured memory_bytes: 17536