#include <bits/stdc++.h>
using namespace std;
using ll = long long;

template <typename T>
struct Compress {
    vector<T> xs;

    Compress(const vector<T>& vs) : xs(vs) {
        sort(xs.begin(), xs.end());
        xs.erase(unique(xs.begin(), xs.end()), xs.end());
    }

    int compress(const T& x) {
        return lower_bound(xs.begin(), xs.end(), x) - xs.begin();
    }

    T decompress(int i) {
        return xs[i];
    }
};

struct SuffixArray {
    vector<int> sa;
    const vector<int> s;

    SuffixArray(const vector<int>& str) : s(str) {

        int n = s.size();
        sa.resize(n);
        Compress<int> comp(s);
        vector<int> t(n);
        for (int i = 0; i < n; i++) t[i] = comp.compress(s[i]);
        vector<int> c(n), cnt(n);
        for (int i = 0; i < n; i++) cnt[t[i]]++;
        for (int i = 1; i < n; i++) cnt[i] += cnt[i-1];
        for (int i = 0; i < n; i++) sa[--cnt[t[i]]] = i;
        int cl = 0;
        for (int i = 1; i < n; i++) {
            if (s[sa[i]] != s[sa[i-1]]) cl++;
            c[sa[i]] = cl;
        }
        vector<int> pn(n), cn(n);
        for (int k = 1; k < n; k *= 2) {
            for (int i = 0; i < n; i++) {
                pn[i] = sa[i] - k;
                if (pn[i] < 0) pn[i] += n;
            }
            fill(cnt.begin(), cnt.end(), 0);
            for (int i = 0; i < n; i++) cnt[c[pn[i]]]++;
            for (int i = 1; i < n; i++) cnt[i] += cnt[i-1];
            for (int i = n - 1; i >= 0; i--) {
                cnt[c[pn[i]]]--;
                sa[cnt[c[pn[i]]]] = pn[i];
            }
            cn[sa[0]] = 0;
            cl = 0;
            for (int i = 1; i < n; i++) {
                pair<int, int> cur(c[sa[i]], c[(sa[i] + k) % n]);
                pair<int, int> prev(c[sa[i-1]], c[(sa[i-1] + k) % n]);
                if (cur != prev) cl++;
                cn[sa[i]] = cl;
            }
            swap(c, cn);
        }
    }

    int operator[](int k) const {
        return sa[k];
    }

    bool lt_substr(const vector<int>& t, int si = 0, int ti = 0) {
        int n = s.size();
        for (int i = 0; i < min(s.size(), t.size()); i++) {
            if (s[(si + i) % n] < t[(ti + i) % n]) return true;
            if (s[(si + i) % n] > t[(ti + i) % n]) return false;
        }
        return false;
    }

    int lower_bound(const vector<int>& t) {
        int lb = -1, ub = sa.size();
        while (ub - lb > 1) {
            int m = (lb + ub) / 2;
            if (lt_substr(t, sa[m])) lb = m;
            else ub = m;
        }
        return ub;
    }

    int upper_bound(vector<int>& t) {
        t.back()++;
        int i = lower_bound(t);
        t.back()--;
        return i;
    }
};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int N;
    cin >> N;
    vector<int> a(N), b(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    for (int i = 0; i < N; i++) cin >> b[i];
    vector<int> c(N), d(N);
    for (int i = 0; i < N; i++) {
        c[i] = a[i] ^ a[(i+1) % N];
        d[i] = b[i] ^ b[(i+1) % N];
    }
    SuffixArray sa(d);
    int lb = sa.lower_bound(c);
    int ub = sa.upper_bound(c);
    vector<pair<int, int>> ans;
    for (int i = lb; i < ub; i++) {
        int k = (N - sa[i]) % N;
        int x = a[k] ^ b[0];
        ans.push_back({k, x});
    }
    sort(ans.begin(), ans.end());
    for (auto& p : ans) cout << p.first << " " << p.second << "\n";
}

Measured memory_bytes: 12712