#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
//typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

const ll mod = 1000000007;
const ll INF = 100000000000010000;

ll kai[100010];
ll bit[700010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }

/*ll sum(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(ll i, ll x)
{
	while (i <= 700005)
	{
		bit[i] += x;
		i += i & -i;
	}
}*/

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll y) {
	if (y == 0) return 1;
	if (y % 2 == 1) {
		return x * pow_mod(x, y - 1) % mod;
	}
	else {
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

ll com(ll x, ll y) {
	return kai[x] * div_mod(kai[y] * kai[x - y] % mod) % mod;
}

ll N, k, n;
ll a[200010], b[200010];
ll A[400010], B[200010];
ll ran[400010], sa[400010], tmp[400010];
ll order[400010];
vector<P> ans;

bool compare_sa(ll i, ll j) {
	if (ran[i] != ran[j]) return ran[i] < ran[j];
	else {
		ll ri = i + k <= n ? ran[i + k] : -1;
		ll rj = j + k <= n ? ran[j + k] : -1;
		return ri < rj;
	}
}

void construct_sa() {
	n = 2 * N - 2;
	for (int i = 0; i <= n; i++) {
		sa[i] = i;
		ran[i] = i < n ? A[i] : -1;
	}
	for (k = 1; k <= n; k *= 2) {
		sort(sa, sa + n + 1, compare_sa);
		tmp[sa[0]] = 0;
		for (ll i = 1; i <= n; i++) {
			tmp[sa[i]] = tmp[sa[i - 1]] + (compare_sa(sa[i - 1], sa[i]) ? 1 : 0);
		}
		for (int i = 0; i <= n; i++) {
			ran[i] = tmp[i];
		}
	}
}

bool compare_rank(ll i, ll j) {
	return ran[i] < ran[j];
}

bool compare_string(ll top, ll pt) {
	ll len_b = N - 1, len_a = n - top;
	if (len_b > len_a) {
		for (int i = 0; i < len_a; i++) {
			if (B[i] < A[i + top]) return false;
			if (B[i] > A[i + top]) return true;
		}
		return true;
	}
	else {
		for (int i = 0; i < len_b; i++) {
			if (i == len_b - 1 && pt == 1) {
				if (B[i] + 1 < A[top + i]) return false;
				if (B[i] + 1 > A[top + i]) return true;
			}
			else {
				if (B[i] < A[top + i]) return false;
				if (B[i] > A[top + i]) return true;
			}
		}
		return false;
	}
}

void solve() {
	cin >> N;
	rep(i, N) cin >> a[i];
	rep(i, N) cin >> b[i];
	rep(i, N - 1) {
		B[i] = b[i] ^ b[i + 1];
	}
	rep(i, N - 1) {
		A[i] = a[i] ^ a[i + 1];
		A[i + N] = a[i] ^ a[i + 1];
	}
	A[N - 1] = a[N - 1] ^ a[0];

	construct_sa();
	for (ll i = 0; i <= n; i++) {
		order[i] = i;
	}
	sort(order, order + n + 1, compare_rank);
	ll lb = 0, ub = n + 1;
	while (lb + 1 < ub) {
		ll mid = (ub + lb) / 2;
		if (compare_string(order[mid], 0)) {
			lb = mid;
		}
		else {
			ub = mid;
		}
	}
	ll former = ub;
	lb = 0, ub = n + 1;
	while (lb + 1 < ub) {
		ll mid = (ub + lb) / 2;
		if (compare_string(order[mid], 1)) {
			lb = mid;
		}
		else {
			ub = mid;
		}
	}
	ll latter = ub;
	for (int i = former; i < latter; i++) {
		ans.push_back(P(order[i], (b[0] ^ a[order[i]])));
	}
	sort(ans.begin(), ans.end());
	for (P p : ans) {
		cout << p.f << ' ' << p.s << endl;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	ll N;
	cin >> N;
}
////////////////////////////////////////////////////////////////////////////////////////////jagfhaoi;sd;joi;asdfjzasdi;lfjoi;ernjsdoivcnoizvdfnvdfnon/////////////////////////////////////////////////////////
////////////////////jgoiadhsjgoi;vsjvgfonhjasoivhoivhno

Measured memory_bytes: 27244