#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define Inf 1000000000
#define nmax_def 110000
#define HASHnum 10
#define mod 1000000007LL
#define HASH0 999999937LL
#define HASH1 999999929LL
#define HASH2 999999893LL
#define HASH3 999999883LL
#define HASH4 999999797LL
#define HASH5 999999761LL
#define HASH6 999999757LL
#define HASH7 999999751LL
#define HASH8 999999739LL
#define HASH9 999999733LL
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;

vl HASHlist;
vector<vl> pow_;
void pow_ini() {
    pow_.resize(HASHnum);
    rep(i, HASHnum) {
        pow_[i].clear();
        pow_[i].push_back(HASHlist[i]);
        rep(j, 62) {
            ll nxt = pow_[i][j] * pow_[i][j];
            nxt %= mod;
            pow_[i].push_back(nxt);
        }
    }
    return;
}

ll pow1(int i, ll b) {
    ll ans = 1;
    rep(n, 62) {
        if ((b >> n) % 2 == 1) {
            ans *= pow_[i][n];
            ans %= mod;
        }
    }
    return ans;
}

class Rolling_hash {
public:
    int AN, BN;
    vector<vl> hash_A;
    vector<vl> hash_B;
    vector<vl> hash_sum_A;
    vector<vl> hash_sum_B;
    vector<vl> pow_HASH_inv;
    void h_ini_from_array(vl A, vl B);
    void h_ini_from_string(string A, string B);
    vl hash_val_A(int Ai, int len);
    vl hash_val_B(int Bi, int len);
    bool same(int Ai, int Bi, int len);
};

void Rolling_hash::h_ini_from_array(vl A, vl B) {
    hash_A.resize(HASHnum);
    hash_B.resize(HASHnum);
    hash_sum_A.resize(HASHnum);
    hash_sum_B.resize(HASHnum);
    pow_HASH_inv.resize(HASHnum);
    HASHlist.resize(HASHnum);
    HASHlist[0] = HASH0;
    HASHlist[1] = HASH1;
    HASHlist[2] = HASH2;
    HASHlist[3] = HASH3;
    HASHlist[4] = HASH4;
    HASHlist[5] = HASH5;
    HASHlist[6] = HASH6;
    HASHlist[7] = HASH7;
    HASHlist[8] = HASH8;
    HASHlist[9] = HASH9;
    AN = A.size();
    BN = B.size();
    pow_ini();
    rep(i, HASHnum) {
        hash_A[i].resize(AN);
        hash_B[i].resize(BN);
        hash_sum_A[i].resize(AN + 1);
        hash_sum_B[i].resize(BN + 1);
        hash_sum_A[i][0] = 0;
        hash_sum_B[i][0] = 0;

        ll hashtmp = 1;
        rep(j, AN) {
            hash_A[i][j] = A[j] * hashtmp;
            hash_A[i][j] %= mod;
            hash_sum_A[i][j + 1] = hash_sum_A[i][j] + hash_A[i][j];
            hash_sum_A[i][j + 1] %= mod;
            hashtmp *= HASHlist[i];
            hashtmp %= mod;
        }
        hashtmp = 1;
        rep(j, BN) {
            hash_B[i][j] = B[j] * hashtmp;
            hash_B[i][j] %= mod;
            hash_sum_B[i][j + 1] = hash_sum_B[i][j] + hash_B[i][j];
            hash_sum_B[i][j + 1] %= mod;
            hashtmp *= HASHlist[i];
            hashtmp %= mod;
        }

        int powN = max(AN, BN);
        pow_HASH_inv[i].resize(powN);
        pow_HASH_inv[i][powN - 1] = pow1(i, mod - (ll)powN);
        for (int j = powN - 2; j >= 0; j--) {
            pow_HASH_inv[i][j] = pow_HASH_inv[i][j + 1] * HASHlist[i];
            pow_HASH_inv[i][j] %= mod;
        }
    }
    return;
}

void Rolling_hash::h_ini_from_string(string A, string B) {
    AN = A.length();
    BN = B.length();
    vl Avec(AN);
    vl Bvec(BN);
    rep(i, AN) {
        Avec[i] = (ll)A[i] - (ll)'a' + 1;
    }
    rep(i, BN) {
        Bvec[i] = (ll)B[i] - (ll)'a' + 1;
    }
    h_ini_from_array(Avec, Bvec);
    return;
}

vl Rolling_hash::hash_val_A(int Aj, int len) { // substr(Aj, len)
    vl hash_val(HASHnum);
    rep(i, HASHnum) {
        ll hash_tmp = hash_sum_A[i][Aj + len] - hash_sum_A[i][Aj];
        hash_tmp += mod;
        hash_tmp *= pow_HASH_inv[i][Aj];
        hash_tmp %= mod;
        hash_val[i] = hash_tmp;
    }
    return hash_val;
}

vl Rolling_hash::hash_val_B(int Bj, int len) { // substr(Bj, len)
    vl hash_val(HASHnum);
    rep(i, HASHnum) {
        ll hash_tmp = hash_sum_B[i][Bj + len] - hash_sum_B[i][Bj];
        hash_tmp += mod;
        hash_tmp *= pow_HASH_inv[i][Bj];
        hash_tmp %= mod;
        hash_val[i] = hash_tmp;
    }
    return hash_val;
}

bool Rolling_hash::same(int Ai, int Bi, int len) {
    return (hash_val_A(Ai, len) == hash_val_B(Bi, len));
}

int main() {
	int N;
	cin >> N;
	vl a(N);
	vl b(N);
	rep(i, N) {
		cin >> a[i];
	}
	rep(i, N) {
		cin >> b[i];
	}
	vl a_xor_nei(N);
	vl b_xor_nei(N);
	rep(i, N) {
		int j = ((i + 1) % N);
		a_xor_nei[i] = a[i] ^ a[j];
	}
	rep(i, N) {
		int j = ((i + 1) % N);
		b_xor_nei[i] = b[i] ^ b[j];
	}

    Rolling_hash hashlist;
    hashlist.h_ini_from_array(a_xor_nei, b_xor_nei);
    vl hash_val_Bsum = hashlist.hash_val_B(0, N);
    rep(k, N) {
        vl hash_val_A1 = hashlist.hash_val_A(k, N - k);
        vl hash_val_A2 = hashlist.hash_val_A(0, k);
        vl hash_val_Asum;
        rep(i, HASHnum) {
            ll hashtmp = hash_val_A1[i] + hash_val_A2[i] * pow1(i, N - k);
            hashtmp %= mod;
            hash_val_Asum.push_back(hashtmp);
        }
        if (hash_val_Asum == hash_val_Bsum) {
            ll x = a[k] ^ b[0];
            cout << k << " " << x << endl;
        }
    }

	return 0;
}

Measured memory_bytes: 87880