#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

struct RollingHash {
    static const ull mod1 = (1ULL << 61) - 1, mod2 = (1ULL << 31) - 1;
    static const ull base1 = 9733, base2 = 9973;
    static const ull p1 = mod1 * 3, p2 = mod2 * 2;

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

    RollingHash(vector<int> &S) {
        N = S.size();
        hash1.assign(N + 1, 0);
        hash2.assign(N + 1, 0);
        power1.assign(N + 1, 1);
        power2.assign(N + 1, 1);
        for (int i = 0; i < N; ++i) {
            hash1[i + 1] = calcmod1(mul1(hash1[i], base1) + S[i]);
            hash2[i + 1] = calcmod2(mul2(hash2[i], base2) + S[i]);
            power1[i + 1] = calcmod1(mul1(power1[i], base1));
            power2[i + 1] = calcmod2(mul2(power2[i], base2));
        }
    }

    inline ull mul1(ull a, ull b) {
        ull au = a >> 31, ad = a & mod2;
        ull bu = b >> 31, bd = b & mod2;
        ull c = au * bd + ad * bu;
        ull cu = c >> 30, cd = c & (mod2 >> 1);
        return 2 * au * bu + ad * bd + cu + (cd << 31);
    }

    inline ull mul2(ull a, ull b) {
        ull c = a * b;
        ull cu = c >> 31, cd = c & mod2;
        return cu + cd;
    }

    inline ull calcmod1(ull a) {
        ull au = a >> 61, ad = a & mod1;
        ull res = au + ad;
        if (res >= mod1)
            res -= mod1;
        return res;
    }

    inline ull calcmod2(ull a) {
        while (a >= mod2)
            a -= mod2;
        return a;
    }

    inline pair<ull, ull> get(int l, int r) {
        ull res1 = calcmod1(hash1[r] + p1 - mul1(hash1[l], power1[r - l]));
        ull res2 = calcmod2(hash2[r] + p2 - mul2(hash2[l], power2[r - l]));
        return {res1, res2};
    }

    inline void solve(vector<int> &S, vector<int> &T) {
        int Tlen = T.size();
        if (Tlen > N)
            return;

        pair<ull, ull> t_hash[30][2];
        fill(t_hash[0], t_hash[30], pair<ull, ull>{0, 0});

        for (int i = 0; i < Tlen; ++i) {
            for (int j = 0; j < 30; ++j) {
                int tmp = T[i] & (1 << j);
                t_hash[j][0].first = calcmod1(mul1(t_hash[j][0].first, base1) + tmp);
                t_hash[j][0].second = calcmod2(mul2(t_hash[j][0].second, base2) + tmp);
                tmp = (~T[i]) & (1 << j);
                t_hash[j][1].first = calcmod1(mul1(t_hash[j][1].first, base1) + tmp);
                t_hash[j][1].second = calcmod2(mul2(t_hash[j][1].second, base2) + tmp);
            }
        }

        for (int i = 0; i + Tlen <= N; ++i) {
            int tmp = S[i] ^ T[0];
            pair<ull, ull> s_hash = get(i, i + Tlen);
            pair<ull, ull> hash = {0, 0};
            for (int j = 0; j < 30; ++j) {
                bool flag = tmp & (1 << j);
                hash.first = calcmod1(hash.first + t_hash[j][flag].first);
                hash.second = calcmod2(hash.second + t_hash[j][flag].second);
            }
            if (s_hash == hash)
                cout << i << " " << tmp << '\n';
        }
    }
};

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

    int N;
    cin >> N;
    vector<int> a(2 * N), b(N);
    for (int i = 0; i < N; ++i)
        cin >> a[i], a[i + N] = a[i];
    for (int i = 0; i < N; ++i)
        cin >> b[i];
    a.pop_back();

    RollingHash rhs(a);
    rhs.solve(a, b);

    return 0;
}


Measured memory_bytes: 18304