#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

template <typename T = char>
struct SuffixArrayByDoubling {
    struct SuffixArrayComparer {
        const SuffixArrayByDoubling<T>& sa;
        SuffixArrayComparer(const SuffixArrayByDoubling<T>& sa) : sa(sa) {}
        bool operator ()(int& i, int& j) const {
            if (sa.rank[i] != sa.rank[j]) return sa.rank[i] < sa.rank[j];
            int ri = i + sa.k <= (int)sa.S.size() ? sa.rank[i + sa.k] : -1;
            int rj = j + sa.k <= (int)sa.S.size() ? sa.rank[j + sa.k] : -1;
            return ri < rj;
        }
        template<class String> int operator ()(int& index, String&& t) const {
            for (int i = 0; i < (int)t.size(); ++i) {
                if (sa.sa[index] + i < (int)sa.S.size()) {
                    if (sa.S[sa.sa[index] + i] == t[i]) continue;
                    else return sa.S[sa.sa[index] + i] - t[i];
                }
                else return -1;
            } return 0;
        }
    };
    const SuffixArrayComparer cmp = SuffixArrayComparer(*this);
    vector<T> S; vector<int> sa, rank, tmp, lcp; int k;

    template<class String> void build_sa(String&& s) {
        S.resize(s.size()); sa.resize(S.size() + 1); rank.resize(S.size() + 1); tmp.resize(S.size() + 1);
        for (int i = 0; i < (int)s.size(); ++i) S[i] = s[i];
        for (int i = 0; i <= (int)S.size(); ++i) { sa[i] = i; rank[i] = i < (int)S.size() ? S[i] : -1; }
        for (k = 1; k <= (int)S.size(); k *= 2) {
            sort(sa.begin(), sa.end(), cmp); tmp[sa[0]] = 0;
            for (int i = 1; i <= (int)S.size(); ++i) tmp[sa[i]] = tmp[sa[i - 1]] + (cmp(sa[i - 1], sa[i]) ? 1 : 0);
            for (int i = 0; i <= (int)S.size(); ++i) rank[i] = tmp[i];
        }
    }
    void build_lcp() {
        for (int i = 0; i < S.size(); ++i) rank[sa[i]] = i;
        lcp.resize(S.size()); lcp[0] = 0;
        for (int i = 0, h = 0; i < (int)S.size(); ++i) {
            if (h > 0) h--;
            for (int j = sa[rank[i] - 1]; j + h < (int)S.size() && i + h < S.size(); ++h) {
                if (S[j + h] != S[i + h]) break;
            }
            lcp[rank[i] - 1] = h;
        }
    }
    template<class String> bool contains(String&& t) {
        int l = 0, r = S.size();
        while (r - l > 1) {
            int mid = (l + r) / 2;
            if (cmp(mid, t)) l = mid;
            else r = mid;
        } return cmp(r, t) == 0;
    }
};

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

    if (N == 1) {
        cout << 0 << ' ' << (A[0] ^ B[0]) << endl;
        return 0;
    }

    vector<int> C = A, D = B;
    rep(i, N) C[i] ^= A[(i + 1) % N];
    rep(i, N) D[i] ^= B[(i + 1) % N];
    C.resize(2 * N);
    rep(i, N) C[N + i] = C[i];

    SuffixArrayByDoubling<int> sa;
    sa.build_sa(C);
    int llow = 0, lhigh = 2 * N, hlow = 1, hhigh = 2 * N + 1;
    while (lhigh - llow > 1) {
        int mid = (llow + lhigh) / 2;
        int r = 0;
        rep(i, min(N, 2 * N - mid)) {
            if (D[i] != C[sa.sa[mid] + i]) {
                if (D[i] > C[sa.sa[mid] + i]) r = 1;
                else r = -1;
                break;
            }
        }
        if (r > 0) llow = mid;
        else lhigh = mid;
    }
    while (hhigh - hlow > 1) {
        int mid = (hlow + hhigh) / 2;
        int r = 0;
        rep(i, min(N, 2 * N - mid)) {
            if (D[i] != C[sa.sa[mid] + i]) {
                if (D[i] < C[sa.sa[mid] + i]) r = 1;
                else r = -1;
                break;
            }
        }
        if (r > 0) hhigh = mid;
        else hlow = mid;
    }

    vector<int> ks;
    rep(i, lhigh, hhigh) {
        if (sa.sa[i] >= N) continue;
        ks.push_back(sa.sa[i]);
    }
    sort(all(ks));
    for (int k : ks) {
        cout << k << ' ' << (A[k] ^ B[0]) << endl;
    }
}

Measured memory_bytes: 15472