#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

template<class T>bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#pragma endregion

std::vector<int> createTable(const vector<ll> &);
int getPeriod(const vector<ll> &);

// KMP(Knuth–Morris–Pratt) algorithm KMP(クヌース-モリス-プラット)法
vector<int> KMP(const vector<ll> &target, const vector<ll> &pattern) {
    vector<int> res;
    int len_t = (int)target.size(), len_p = (int)pattern.size();

    std::vector<int> table = createTable(pattern);

    // search pattern in target
    int cur_t = 0, cur_p = 0;
    while (cur_t < len_t && cur_p < len_p) {
        if (target.at(cur_t) == pattern.at(cur_p)) {
            cur_p++; cur_t++;
        } else if (cur_p == 0) {
            cur_t++;
        } else {
            cur_p = table.at(cur_p);
        }
    }
    if (cur_p == len_p) {
        int ind = cur_t - cur_p;
        res.push_back(ind);
        int period = getPeriod(pattern);
        if (period > 0) {
            ind += period;
            while (ind < len_p) {
                res.push_back(ind);
                ind += period;
            }
        }
    }
    return res;
}

// create table
std::vector<int> createTable(const vector<ll> &pattern) {
    int len_p = (int)pattern.size();
    std::vector<int> table(len_p);
    table.at(0) = 0;
    int j = 0;
    for (int i=1; i<len_p; i++) {
        if (pattern.at(i) == pattern.at(j)) {
            table.at(i) = j;
            j++;
        } else {
            table.at(i) = j;
            j = 0;
        }
    }
    return table;
}

// check periodicity of pattern
int getPeriod(const vector<ll> &pattern) {
    int len_p = (int)pattern.size();
    if (len_p == 1) return -1;
    if (len_p == 2) {
        if (pattern.at(0) == pattern.at(1)) {
            return 1;
        } else {
            return -1;
        }
    }

    std::vector<int> table = createTable(pattern);

    int len = (int)table.size();
    bool isPeriodical = true;
    int period;
    if (table.at(len-1) == 0) return -1;
    for (int i=len-2; i>=0; i--) {
        if (table.at(i) == 0) {
            period = i;
            break;
        } else if (table.at(i) != table.at(i+1) - 1) {
            isPeriodical = false;
        }
    }
    if (!isPeriodical || len%period != 0) {
        return -1;
    } else {
        return period;
    }
}

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
    }
    vector<ll> b(n);
    for (int i=0; i<n; i++) {
        cin >> b.at(i);
    }
    vector<ll> xora(n), xorb(n);
    for (int i=0; i<n; i++) {
        if (i == 0) {
            xora.at(i) = (a.at(0) ^ a.at(n-1));
            xorb.at(i) = (b.at(0) ^ b.at(n-1));
        } else {
            xora.at(i) = (a.at(i) ^ a.at(i-1));
            xorb.at(i) = (b.at(i) ^ b.at(i-1));
        }
    }
    for (int i=0; i<n; i++) {
        xora.push_back(xora.at(i));
    }
    vector<int> inds = KMP(xora, xorb);
    for (int ind : inds) {
        cout << ind << " " << (a.at(ind) ^ b.at(0)) << "\n";
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 13924