#include <bits/stdc++.h>

using namespace std;
const int N = 2e5 + 5, LOG = 30;
int A[N], B[N], cnt[N], f[N], w[N], n;
bool a[N], b[N];

void Check() {
    int curr = 0;
    for (int i = 2; i <= n; i ++) {
        while (curr && b[curr] != b[i - 1]) curr = f[curr];
        if (b[curr] == b[i - 1]) curr++;
        f[i] = curr;
    }
    curr = 0;
    for (int i = 1; i <= n; i++) {
        while (curr && b[curr] != a[i - 1]) curr = f[curr];
        if (b[curr] == a[i - 1]) curr++;
    }
    memset(w, 0, sizeof w);
    while (curr) w[curr] = 1, curr = f[curr];
    w[0] = 1;
    for (int i = 2; i <= n; i ++) {
        while (curr && a[curr] != a[i - 1]) curr = f[curr];
        if (a[curr] == a[i - 1]) curr++;
        f[i] = curr;
    }
    curr = 0;
    for (int i = 1; i <= n; i++) {
        while (curr && a[curr] != b[i - 1]) curr = f[curr];
        if (a[curr] == b[i - 1]) curr++;
    }
    while (curr) {
        if (w[n - curr] == 1) cnt[curr]++;
        curr = f[curr];
    }
    if (w[n] == 1) cnt[0]++;
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) cin >> A[i];
    for (int i = 0; i < n; i++) cin >> B[i];
    for (int j = 0; j < LOG; j++) {
        for (int i = 0; i < n; i++) a[i] = (A[i]>>j)&1, b[i] = (B[i]>>j)&1;
        Check();
        for (int i = 0; i < n; i++) a[i] ^= 1;
        Check();
    }
    for (int i = 0; i < n; i++) if (cnt[i] == LOG) cout << i << " " << (A[i]^B[0]) << "\n";
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int B = 100000007;
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
lint power(lint x, lint n, lint mod) {
  lint ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= mod;
    (x *= x) %= mod;
    n >>= 1;
  }
  return ret;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N;
  cin >> N;
  vector<lint> a(N);
  REP(i, N) cin >> a[i];
  vector<lint> b(N);
  REP(i, N) cin >> b[i];
  vector<lint> pa(N);
  vector<lint> pb(N);
  REP(i, N) {
    pa[i] = a[i] ^ a[(i+1)%N];
    pb[i] = b[i] ^ b[(i+1)%N];
  }
  lint hash = 0;
  lint target = 0;
  REP(i, N) {
    hash = (hash + pa[i]*power(B, i, MOD)) % MOD;
    target = (target + pb[i]*power(B, i, MOD)) % MOD;
  }
  vector<pair<lint, lint>> ans;
  REP(i, N) {
    //cout << hash << " " << target << endl;
    if(hash == target) {
      lint x = b[0] ^ a[i];
      ans.push_back(make_pair(i, x));
    }
    hash = hash * power(B, MOD-2, MOD) % MOD;
    hash = (hash - pa[i]*power(B, MOD-2, MOD) % MOD + pa[i]*power(B, N-1, MOD) + MOD) % MOD;
  }
  sort(ans.begin(), ans.end(), [](auto const &a, auto const &b) { return a.first < b.first; });
  REP(i, ans.size()) {
    cout << ans[i].first << " " << ans[i].second << "\n";
  }

}