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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q;
int arr[N + 2], brr[N], a1[N], b1[N];
//mafia-->: hash_it

#define pii pair<int,int>

const int MAX_LEN = (int)2e5 + 17; // check it
pii p_pwr[MAX_LEN];
int p1 = 40, p2 = 34, mod1 = (int)1e9 + 9, mod2 = (int)1e7 + 79; // --> check it
int mxp = MAX_LEN - 1;
auto clk = clock();
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int l, int r) {
	uniform_int_distribution<int> uid(l, r);
	return uid(rang);
}

void pre()
{
	p_pwr[0].ff = 1; for (int i = 1; i < MAX_LEN; i++) p_pwr[i].ff = (1LL * p_pwr[i - 1].ff * p1) % mod1;
	p_pwr[0].ss = 1; for (int i = 1; i < MAX_LEN; i++) p_pwr[i].ss = (1LL * p_pwr[i - 1].ss * p2) % mod2;
}

inline int add(int a, int b, int &mod) { b %= mod; int res = a + b;        return res >= mod ? res - mod : res; }
inline int sub(int a, int b, int &mod) { b %= mod; int res = a - b;        return res < 0 ? res + mod : res; }
inline int mul(int a, int b, int &mod) { b %= mod; int res = (1LL * a * b) % mod;   return res; }

class hash_it {
public:
	static int cnt;
	int len, d; vector<pii> hashes;
	inline int get(int x) {   return x + 1; } // check  it( x-'a'+1)

	void init(int *s, int d1, int l)
	{
		len = l; d = d1;
		hashes.resize(len + 1);
		for (int i = 0, val1 = 0, val2 = 0; i < len; i++)
		{
			val1 = add(val1, mul( get(s[i]), p_pwr[i].ff, mod1), mod1);       hashes[i].ff = val1;
			if (d) val2 = add(val2, mul( get(s[i]), p_pwr[i].ss, mod2), mod2);         hashes[i].ss = val2;
		}
	}

	pii  get(int i,  int j)
	{
		pii v1 = {0, 0};
		v1.ff = mul( sub(hashes[j].ff, (i ? hashes[i - 1].ff : 0), mod1), p_pwr[0].ff, mod1);
		if (d)v1.ss = mul( sub(hashes[j].ss, (i ? hashes[i - 1].ss : 0), mod2), p_pwr[0].ss, mod2);
		return v1;
	}
};


void prepre()
{
	p1 = rng(31, 100);  // check range
	p2 = rng(31, 100);  // check range
	if ( p1 > 50 ) swap(mod1, mod2);
	mxp = MAX_LEN - 3;
	pre();
}


void solve()
{
	cin >> n;
	lop(i, 0, n) cin >> arr[i];
	lop(i, 0, n) cin >> brr[i];

	lop(i, 0, n) a1[i] = (arr[i] ^ arr[ (i + 1) % n]);
	lop(i, 0, n) b1[i] = (brr[i] ^ brr[ (i + 1) % n]);

	// prarr(a1, 0, n);
	// prarr(b1, 0, n);
	hash_it h1, h2;
	h1.init(a1, 0, n);
	h2.init(b1, 0, n);

	int x1 = h1.hashes[n - 1].ff;
	int x2 = h2.hashes[n - 1].ff;

	// cout << x1 << " " << x2 << endl;
	x1 = h1.get(0, n - 1).ff;
	x2 = h2.get(0, n - 1).ff;

	// cout << x1 << " " << x2 << endl;
	vector<pii> vec;
	if ( x1 == x2 ) vec.pb({0, -1});
	for (int i = 1; i <= n; i++)
	{
		x2 = sub(x2, mul((b1[n - i] + 1) % mod1, p_pwr[n - 1].ff, mod1), mod1);
		x2 = mul(x2, p1, mod1);
		x2 = add(x2, (b1[n - i] + 1) % mod1, mod1);
		// cout << x2 <<  " : " << b1[n - i] << endl;
		if ( i < n and x2 == x1 ) vec.pb({i, -1});
	}

	for (auto &i : vec)
	{
		int x = (arr[i.ff] ^ brr[0]);
		i.ss = x;
	}

	for (auto &i : vec) cout << i.ff << " " << i.ss << endl;


}

int32_t main()
{
	ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);
	prepre();

	int test = 1;
	// cin >> test;
	while (test--)solve();


}





Measured memory_bytes: 23144