#include "bits/stdc++.h"
using namespace std;
#include "string"
#define int long long
#define pi pair <int, int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define endl '\n'

vector < int > preffix(vector < int > &a) {
	vector < int > pf(a.size(), 0);
	for(int i = 1; i < a.size(); i++) {
		int j = pf[i - 1];
		while(j > 0 && a[j] != a[i])
			j = pf[j - 1];
		if(a[j] == a[i])
			pf[i] = j + 1;
	}
	return pf;
}

vector < int > kmp(vector < int > &s, vector < int > &t) {
	vector < int > ans;
	auto pf = preffix(t);
	int j = 0;
	for(int i = 0; i < s.size(); i++) {
		while(j > 0 && s[i] != t[j])
			j = pf[j - 1];
		if(s[i] == t[j]) {
			j++;
			if(j == t.size()) {
				ans.push_back(i - j + 1);
				j = pf[j - 1];
			}
		}		
	}
	return ans;
}

int32_t main() {
	boost;
	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];
		a.push_back(a[i]);
	}
	vector < int > s, t;
	for(int i = 1; i < 2 * n - 1; i++)
		s.push_back(abs(a[i] ^ a[i - 1]));
	for(int i = 1; i < n; i++)
		t.push_back(abs(b[i] ^ b[i - 1]));
	auto ans = kmp(s, t);
	for(auto x : ans)
		cout << x << ' ' << (a[x] ^ b[0]) << endl;
} 