#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

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

    int n;
    cin >> n;

    vector<int> a(n), b(n), c(n), d(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }

    c[0] = a[n - 1] ^ a[0];
    d[0] = b[n - 1] ^ b[0];
    for (int i = 1; i < n; i++) {
        c[i] = a[i - 1] ^ a[i];
        d[i] = b[i - 1] ^ b[i];
    }

    ll h = 0;
    for (int i = 0; i < n; i++) {
        h <<= 31;
        h += d[i];
        h %= P;
    }
    ll h0 = h;

    h = 1;
    for (int i = 0; i < n; i++) {
        h <<= 31;
        h %= P;
    }
    ll h1 = h;

    h = 0;
    for (int i = 0; i < n; i++) {
        h <<= 31;
        h += c[i];
        h %= P;
    }
    for (int i = 0; i < n; i++) {
        if (h == h0) {
            cout << i << ' ' << (a[i] ^ b[0]) << '\n';
        }
        h <<= 31;
        h -= c[i] * h1;
        h += c[i];
        h %= P;
        if (h < 0) h += P;
    }

    return 0;
}