#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
const ll fact_table = 800008;
double Pi = 3.1415926535897932384626;
 
//vector<ll> G[550010];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
//ll mod = 998244353;
ll mod = 1000000007;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,a,b,c,d,e,g,h,w,i,j,q,r,l;
ll k;
ll ans;
ll x[500005], y[500005], z[200005];
char s[500005];
ll dp[104][104][104];
ll query;
ll len[105];

struct LLRollingHash {
// long long に対するRollingHash
public:
    ll n1, n2;
    ll max_n;
    ll base1, base2;
    ll mod1, mod2;
    vector<ll> base_table = {128ll, 243ll, 125ll,
                             1340132568ll, 1025585316ll, 216ll};
    vector<ll> mod_table =  {2000000011ll, 2000000033ll, 2000000063ll,
                             2147467057ll, 2147483353ll, 3000001811ll};
    vector<ll> base1_pow, base2_pow;
    vector<ll> table11, table12, table21, table22;

    LLRollingHash(vector<ll> v1, vector<ll> v2) {
        n1 = v1.size();
        n2 = v2.size();
        max_n = max(n1, n2);
        table11.resize(n1 + 1, 0ll);table12.resize(n1 + 1, 0ll);
        table21.resize(n2 + 1, 0ll);table22.resize(n2 + 1, 0ll);
        base1_pow.resize(max_n + 1, 1ll);base2_pow.resize(max_n + 1, 1ll);
        ll idx1 = clock() % 3, idx2 = 3 + clock() % 3;
        base1 = base_table[idx1], base2 = base_table[idx2];
        mod1 = mod_table[idx1], mod2 = mod_table[idx2];
        ll tmp1 = 0, tmp2 = 0;
        for(ll i=0;i<n1;i++){
            tmp1 = tmp1 * base1 + v1[i];
            tmp2 = tmp2 * base2 + v1[i];
            tmp1 %= mod1;
            tmp2 %= mod2;
            table11[i+1] = tmp1;
            table12[i+1] = tmp2;
        }
        tmp1 = 0; tmp2 = 0;
        for(ll i=0;i<n2;i++){
            tmp1 = tmp1 * base1 + v2[i];
            tmp2 = tmp2 * base2 + v2[i];
            tmp1 %= mod1;
            tmp2 %= mod2;
            table21[i+1] = tmp1;
            table22[i+1] = tmp2;
        }
        for(ll i=0;i<max_n;i++){
            base1_pow[i+1] = (base1_pow[i] * base1) % mod1;
            base2_pow[i+1] = (base2_pow[i] * base2) % mod2;
        }

    }

    bool check(ll n, ll idx1, ll idx2){
        // 一つ目の配列のidx1番目(0-index)からn文字と
        // 二つ目の配列のidx2番目(0-index)からn文字が一致するかどうかを確かめる
        assert(idx1 + n <= n1);
        assert(idx2 + n <= n2);
        ll mod1pow = mod1 - base1_pow[n];
        ll mod2pow = mod2 - base2_pow[n];
        ll hash11, hash12, hash21, hash22;
        hash11 = (table11[n + idx1] + (table11[idx1] * mod1pow)) % mod1;
        hash12 = (table12[n + idx1] + (table12[idx1] * mod2pow)) % mod2;
        hash21 = (table21[n + idx2] + (table21[idx2] * mod1pow)) % mod1;
        hash22 = (table22[n + idx2] + (table22[idx2] * mod2pow)) % mod2;
        if(hash11 == hash21 && hash12 == hash22){
            return true;
        }else{
            return false;
        }
    }
};

 
int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n;
    for(ll i=0;i<n;i++){
        cin >> x[i];
        x[i + n] = x[i];
    }
    for(ll i=0;i<n;i++){
        cin >> y[i];
    }
    m = n - 1;
    n = 2 * n - 2;
    vector<ll> xxor, yxor;
    for(ll i=0;i<n;i++){
        xxor.pb(x[i] ^ x[i+1]);
    }
    for(ll i=0;i<m;i++){
        yxor.pb(y[i] ^ y[i+1]);
    }
    LLRollingHash roll(xxor, yxor);
    ll idx = 0;
    while(true){
        bool res = roll.check(m, idx, 0);
        if(res){
            pe(idx);
            ll dif = x[idx] ^ y[0];
            p(dif);
        }
        idx++;
        if(idx + m > n)break;
    }


    return 0;
}







Measured memory_bytes: 46900