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

template <class T, typename T::value_type D>
struct Find {
    Find(const T &s, const T &t) : m(t.size()), o(t.size() * 2 + 1), a(o + s.size()) {
        auto at = [&](size_t i) {
            return i < t.size() ? t[i] : i == t.size() ? D : s[(i - t.size() - 1) % s.size()];
        };
        int j = a[0] = -1;
        for (size_t i = 0; i < a.size() - 1; i++) {
            while (j >= 0 && at(i) != at(j)) j = a[j];
            a[i + 1] = ++j;
        }
    }
    int operator[](int i) const {
        return a[o + i] == m;
    }
    const int m, o;
    vector<int> a;
};

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];
    }

    Find<vector<int>, 1 << 30> u(c, d);

    for (int i = 0; i < n; i++) {
        if (u[i]) cout << i << ' ' << (a[i] ^ b[0]) << '\n';
    }

    return 0;
}