#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const double PI = acos(-1.0);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

struct RandomNumberGenerator {
  mt19937 mt;

  RandomNumberGenerator() : mt(chrono::steady_clock::now().time_since_epoch().count()) {}

  int operator()(int a, int b) { // [a, b)
    uniform_int_distribution< int > dist(a, b - 1);
    return dist(mt);
  }

  int operator()(int b) { // [0, b)
    return (*this)(0, b);
  }
};

RandomNumberGenerator RNG;
const unsigned long long base1 = RNG(1000000005,1<<30);
const unsigned long long base2 = RNG(1000000005,1<<30);

template <typename S>
struct RollingHash {
    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 POSITIVIZER = mod * 3;

    vector<ull> hash1,hash2,power1,power2;

    RollingHash(const S &s) {
        int sz = s.size();
        hash1.assign(sz + 1,0);
        hash2.assign(sz + 1,0);
        power1.assign(sz + 1,1);
        power2.assign(sz + 1,1);
        for (int i = 0; i < sz; i++) {
            power1[i+1] = CalcMod(Mul(power1[i],base1));
            hash1[i+1] = CalcMod(Mul(hash1[i],base1) + s[i] + 1);
            power2[i+1] = CalcMod(Mul(power2[i],base2));
            hash2[i+1] = CalcMod(Mul(hash2[i],base2) + s[i] + 1);
        }
    }

    pair<ull,ull> get(int l, int r) { // [l,r) (0-indexed)
        pair<ull,ull> res;
        res.first = CalcMod(hash1[r] + POSITIVIZER - Mul(hash1[l],power1[r-l]));
        res.second = CalcMod(hash2[r] + POSITIVIZER - Mul(hash2[l],power2[r-l]));
        return res;
    }

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

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

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

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    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];
    RollingHash<vector<ll>> RHA(P),RHB(Q);
    vector<pll> ans;
    rep(i,N) {
        if (RHA.get(i,i+N)==RHB.get(0,N)) {
            ans.emplace_back(i,A[i]^B[0]);
        }
    }

    for (auto i : ans) cout << i.first << " " << i.second << ln;
}


Measured memory_bytes: 33644