#include <bits/stdc++.h>

using namespace std;

vector<int> prefix_function(const vector<int> &s){
	int n = (int)s.size(); vector<int> b(n+1);
	b[0] = -1; int i = 0, j = -1;
	while(i < n){
		while(j >= 0 && s[i] != s[j]) j = b[j];
		b[++i] = ++j;
	}
	return b;
}
vector<bool> kmp(const vector<int> &t, const vector<int> &p){
	vector<int> b = prefix_function(p);
	int n = (int)t.size(), m = (int)p.size();
	vector<bool> occ(n);
	int j = 0;
	for(int i = 0; i < n; i++){
		while(j >= 0 && t[i] != p[j]) j = b[j];
		j++;
		if(j == m){
			occ[i - m + 1] = true;
			j = b[j];
		}
	}
	return occ;
}

const int N = 200005;

int cant[N], ans[N];

void solve(int bit, const vector<int> &a, const vector<int> &b) {
	vector<int> c(b.size());
	for(size_t i = 0; i < b.size(); i++) {
		c[i] = !b[i];
	}
	auto occ = kmp(a, b);
	auto occ_rev = kmp(a, c);
	for(int i = 0; i < (int)b.size(); i++) {
		if(!occ[i] and !occ_rev[i]) cant[i] = true;
		else if(occ_rev[i]) ans[i] |= 1 << bit;
	}
}

int main() {

	int n;
	scanf("%d", &n);
	vector<int> a(n), b(n);
	for(int &x : a) scanf("%d", &x);
	for(int &x : b) scanf("%d", &x);

	vector<int> ta(2 * n), tb(n);
	for(int bit = 0; bit < 30; bit++) {
		for(int i = 0; i < n; i++) {
			ta[i] = ta[n + i] = a[i] >> bit & 1;
			tb[i] = b[i] >> bit & 1;
		}
		solve(bit, ta, tb);
	}

	for(int i = 0; i < n; i++) {
		if(!cant[i]) {
			printf("%d %d\n", i, ans[i]);
		}
	}
}
