#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);
        iota(sa.begin(), sa.end(), 0);
        sort(sa.begin(), sa.end(), [&](int i, int j) {
            return s[i] == s[j] ? i > j : s[i] < s[j];
        });
        int cl = 0;
        vector<int> rank(n);
        for (int i = 1; i < n; i++) {
            if (s[sa[i-1]] != s[sa[i]]) cl++;
            rank[sa[i]] = cl;
        }
        vector<int> pn(n), tmp(n), cnt(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[rank[pn[i]]]++;
            for (int i = 1; i < n; i++) cnt[i] += cnt[i-1];
            for (int i = n - 1; i >= 0; i--) sa[--cnt[rank[pn[i]]]] = pn[i];
            tmp[sa[0]] = 0;
            cl = 0;
            for (int i = 1; i < n; i++) {
                if (rank[sa[i-1]] != rank[sa[i]] || rank[(sa[i-1] + k) % n] != rank[(sa[i] + k) % n]) {
                    cl++;
                }
                tmp[sa[i]] = cl;
            }
            swap(rank, tmp);
        }
    }

    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: 11064