#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////
struct Zalgorithm{
    vector<int> Z;
    Zalgorithm(vi s){
        Z.resize(s.size());
        Z[0]=s.size();
    }

    vector<int> Zeach(vi s){
        int i=1,j=0;
        while(i<Z[0]){
            while(i+j<Z[0]&&s[j]==s[i+j]) j++;
            Z[i]=j;
            if(j==0){
                i++;
                continue;
            }
            int k=1;
            while(k+Z[k]<j){
                Z[i+k]=Z[k];
                k++;
            }
            i+=k;
            j-=k;
        }
        return Z;
    }

    int Zmax(vi s){
        int ans=0;
        for(auto can:Zeach(s)){
            ans=max(ans,can);
        }
        return ans;
    }
};
void solve(){
    int n;
    cin >> n;
    vi a(n), b(n);
    rp(i,n) cin >> a.at(i);
    rp(i,n) cin >> b.at(i);
    vi xa(n),xb(n);
    rp(i,n){
        xa.at(i)=a.at(i)^a.at((i+1)%n);
        xb.at(i)=b.at(i)^b.at((i+1)%n);
    }
    rp(i,n) {
        xa.pb(xa.at(i));
        xb.pb(xb.at(i));
    }
    Zalgorithm zal(xb);
    vi z=zal.Zeach(xb);
    int ctr=1;
    repi(i,1,n){
        if(z[i]>=n) ctr++;
    }
    
    bool allok=false;
    int pos=-1;
    rp(i,n){
        if(xa[i]==xb[0]){
            bool ok=true;
            rp(j,n){
                if(xa[i+j]!=xb[j]){
                    ok=false;
                    i=i+j-1;
                    break;
                }
            }
            
            if(ok){
                allok=true;
                pos=i;
                break;
            }
        }
    }
    vi k;
    if(allok){
        for(int i=pos; i<n; i+=n/ctr){
            k.pb(i);
        }
        for(auto kk:k){
            princ(kk);
            print(b[0]^a[kk]);
        }
    }
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 13636