#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n, base = 1531, mod = 1e9 + 7;
vector <int> a, b;

int powlog(int a, int b){
    if(b == 0) return 1;
    int ret = powlog(a, b / 2);
    if(b % 2) return 1LL * ret * ret % mod * a % mod;
    return 1LL * ret * ret % mod;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    a.resize(n);
    for(auto &i : a) cin >> i;
    b.resize(n);
    for(auto &i : b) cin >> i;
    vector <int> c(n), d(n);
    for(int i = 0 ; i < n ; i++){
        c[i] = a[i] ^ a[(i + 1) % n];
        d[i] = b[i] ^ b[(i + 1) % n];
    }
    for(int i = 0 ; i < n ; i++){
        c.push_back(c[i]);
    }
    int h = 0;
    for(int i = 0 ; i < n - 1 ; i++){
        h = (1LL * h * base + d[i]) % mod;
    }
    int g = 0;
    for(int i = 0 ; i + 2 < 2 * n ; i++){
        g = (1LL * g * base + c[i]) % mod;
        if(i >= n - 1){
            g = (g - 1LL * c[i - (n - 1)] * powlog(base, n - 1) % mod + mod) % mod;
        }
        if(i >= n - 2 && g == h){
            int j = (i - (n - 2)) % n;
            cout << j << " " << (a[j] ^ b[0]) << "\n";
        }
    }
}
