#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
 
vector<int> Zalgo(const vector<int> &s){
    int N=s.size();
    vector<int> z(N,0);
    z[0]=N;
    int i=1,j=0;
    while(i<N){
        int c = s[i]^s[0]; 
        while(i+j<N && (s[i+j]^s[j])==c)j++;
        z[i]=j;
        if(j==0){i++;continue;}
        int k=1;
        while(i+k<N && z[k]+k < j){
            z[i+k]=z[k];
            k++;
        }
        i+=k;j-=k;
    }
    return z;
}
 
int main(){
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> vec(3*N);
    REP(i,N) {
        int a; cin >> a;
        vec[i+N] = a;
        vec[i+2*N] = a;
    }
    REP(i,N) {
        int b; cin >> b;
        vec[i] = b;
    }
    vector<int> z = Zalgo(vec);
    FOR(i,N,2*N) {
        if(z[i]>=N) cout << i-N << ' ' << (vec[0]^vec[i]) << '\n';
    }
    return 0;
}