#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int32_t main(){
	int n;
	cin >> n;
	int a[2*n], b[n], xori = 0, xora = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i], a[i+n] = a[i];
		xora ^= a[i];
	}
	for(int i = 0; i < n; i++){
		cin >> b[i];
		xori ^= b[i];
	}
	int preA[2*n+10];
	preA[0] = a[0];
	for(int i = 1; i < 2*n; i++){
		preA[i] = preA[i-1] ^ a[i];
	}
	vector<pair<int,int>> ans;
	for(int i = 0; i < n; i++){
		int res = xora ^ xori;
		int w = 100;
		unordered_map<int,int> m;
		while(w--){
			int p = rng() % n;
			m[a[i+p]^b[p]]++;
			if(m.size() >= 2)
				break;
		}
		if(m.size() == 1 && res == 0){
			ans.push_back(make_pair(i,(*(m.begin())).F));
		}
		else if(m.size() == 1 && (*(m.begin())).F == res){
			ans.push_back(make_pair(i,res));
		}
	}
	for(auto x : ans)
		cout << x.F << " " << x.S << endl;

	return 0;
}

