#include <bits/stdc++.h>
using namespace std;
#define ll long long

ll mod = 1e9+7;
ll t = 1234569;

int main() {
    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];
    for (int i = 0; i < N; i++) {
        c[i] = a[i]^a[(i+1)%N];
        d[i] = b[i]^b[(i+1)%N];
        //cout << c[i] << " " << d[i] << endl;
    }
    ll h = c[0];
    for (int i = 1; i < N; i++) h = (h*t+c[i])%mod;
    vector<ll> hash(2*N);
    hash[0] = d[0];
    for (int i = 1; i < 2*N; i++) {
        hash[i] = (hash[i-1]*t+d[i%N])%mod;
    }
    ll e = 1;
    for (int i = 0; i < N; i++) e = e*t%mod;
    vector<ll> ans;
    for (int i = 0; i < N; i++) {
        if (((hash[i+N]-hash[i]*e)%mod+mod)%mod == h) {
            ans.push_back(N-1-i);
        }
    }
    reverse(ans.begin(), ans.end());
    for (int i = 0; i < (int)ans.size(); i++) {
        cout << ans[i] << " " << (b[0]^a[ans[i]]) << endl;
    }
    return 0;
}
