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

const int maxN = 5e5 + 100, base = 13, m1 = 1e9 + 7, m2 = 1e9 + 9;

int n, a[maxN + 1], b[maxN + 1];
int ha[2][35][maxN + 1], hb[2][35], hc[2][35];
int pw[2][maxN + 1], ans[35][maxN + 1];

inline int read()
{
	int num = 0, f = 1;
	char ch = getchar();
	while( !isdigit( ch ) ) { if(ch == '-') f = -1; ch = getchar(); }
	while( isdigit( ch ) ) num = (num << 3) + (num << 1) + (ch ^ 48), ch = getchar();
	return num * f;
}

int main()
{
	n = read();
	for(int i = 1; i <= n; i++) a[i] = a[i + n] = read();
	for(int i = 1; i <= n; i++) b[i] = read();

	pw[0][0] = pw[1][0] = 1;
	for(int i = 1; i <= 2 * n; i++) pw[0][i] = 1ll * pw[0][i - 1] * base % m1, pw[1][i] = 1ll * pw[1][i - 1] * base % m2;

	for(int i = 1; i <= 2 * n; i++)
		for(int j = 0; j < 30; j++)
		{
			int x = (a[i] >> j) & 1;
			ha[0][j][i] = (1ll * ha[0][j][i - 1] * base % m1 + x) % m1;
			ha[1][j][i] = (1ll * ha[1][j][i - 1] * base % m2 + x) % m2;
		}

	for(int i = 1; i <= n; i++)
		for(int j = 0; j < 30; j++)
		{
			int x = (b[i] >> j) & 1;
			hb[0][j] = (1ll * hb[0][j] * base % m1 + x) % m1;
			hb[1][j] = (1ll * hb[1][j] * base % m2 + x) % m2;
		}

	for(int i = 1; i <= n; i++)
		for(int j = 0; j < 30; j++)
		{
			int x = ((~b[i]) >> j) & 1;
			hc[0][j] = (1ll * hc[0][j] * base % m1 + x) % m1;
			hc[1][j] = (1ll * hc[1][j] * base % m2 + x) % m2;
		}

	for(int i = 1; i <= n; i++)
		for(int j = 0; j < 30; j++)
		{
			int t1 = ((ha[0][j][i + n - 1] - 1ll * ha[0][j][i - 1] * pw[0][n] % m1) % m1 + m1) % m1;
			int t2 = ((ha[1][j][i + n - 1] - 1ll * ha[1][j][i - 1] * pw[1][n] % m2) % m2 + m2) % m2;
			if(t1 == hb[0][j] && t2 == hb[1][j]) ans[j][i] = 0;
			else if(t1 == hc[0][j] && t2 == hc[1][j]) ans[j][i] = 1;
				else ans[j][i] = -1;
		}

	for(int i = 1; i <= n; i++)
	{
		bool flag = true;
		for(int j = 0; j < 30; j++)
			if(ans[j][i] == -1) { flag = false; break; }
		if(!flag) continue;
		int res = 0;
		for(int j = 0; j < 30; j++) res |= (ans[j][i] << j);
		printf("%d %d\n", i - 1, res);
	}
	return 0;
}

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

vector<int> suffix_array(vector<int>& s) {
    int n = s.size();
    vector<int> p(n), c(n), cnt(n);
    for (int i = 0; i < n; i++) cnt[s[i]]++;
    for (int i = 1; i < n; i++) cnt[i] += cnt[i-1];
    for (int i = 0; i < n; i++) p[--cnt[s[i]]] = i;
    int cl = 0;
    for (int i = 1; i < n; i++) {
        if (s[p[i]] != s[p[i-1]]) cl++;
        c[p[i]] = cl;
    }
    vector<int> pn(n), cn(n);
    for (int h = 0; (1 << h) < n; h++) {
        for (int i = 0; i < n; i++) {
            pn[i] = p[i] - (1 << h);
            if (pn[i] < 0) pn[i] += n;
        }
        fill(cnt.begin(), cnt.end(), 0);
        for (int i = 0; i < n; i++) cnt[c[pn[i]]]++;
        for (int i = 1; i < n; i++) cnt[i] += cnt[i-1];
        for (int i = n - 1; i >= 0; i--) {
            cnt[c[pn[i]]]--;
            p[cnt[c[pn[i]]]] = pn[i];
        }
        cn[p[0]] = 0;
        cl = 0;
        for (int i = 1; i < n; i++) {
            pair<int, int> cur(c[p[i]], c[(p[i] + (1 << h)) % n]);
            pair<int, int> prev(c[p[i-1]], c[(p[i-1] + (1 << h)) % n]);
            if (cur != prev) cl++;
            cn[p[i]] = cl;
        }
        swap(c, cn);
    }
    return p;
}

int bin_search(vector<int>& a, vector<int>& b, vector<int>& sa, bool lower) {
    int n = a.size();
    int lb = -1, ub = n;
    while (ub - lb > 1) {
        int m = (lb + ub) / 2;
        bool flag = false;
        for (int i = 0; i < n; i++) {
            int j = (sa[m] + i) % n;
            if (a[i] < b[j]) {
                ub = m;
                flag = true;
                break;
            }
            if (a[i] > b[j]) {
                lb = m;
                flag = true;
                break;
            }
        }
        if (!flag) {
            if (lower) ub = m;
            else lb = m;
        }
    }
    return ub;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int N;
    cin >> N;
    vector<int> a(N), b(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    for (int i = 0; i < N; i++) cin >> b[i];
    vector<int> cnt(N);
    for (int i = 0; i < 30; i++) {
        vector<int> c(N), d(N);
        for (int j = 0; j < N; j++) {
            c[j] = a[j] >> i & 1;
            d[j] = b[j] >> i & 1;
        }
        auto sa = suffix_array(d);
        int lb = bin_search(c, d, sa, true);
        int ub = bin_search(c, d, sa, false);
        for (int j = lb; j < ub; j++) cnt[(N - sa[j]) % N]++;

        for (int j = 0; j < N; j++) c[j] = 1 - c[j];
        lb = bin_search(c, d, sa, true);
        ub = bin_search(c, d, sa, false);
        for (int j = lb; j < ub; j++) cnt[(N - sa[j]) % N]++;
    }
    for (int k = 0; k < N; k++) {
        if (cnt[k] == 30) {
            int x = a[k] ^ b[0];
            cout << k << " " << x << "\n";
        }
    }
}