#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5,mod=1e9+7;
int n,a[N],b[N],c[N],d[N];
int vis[N];
ll p[N];
void solve()
{
    reverse(c+1,c+1+n);
    reverse(d+1,d+1+n);
    ll res=0,sum=0,mus=0;
    for(int i=1;i<=n;i++)
    {
        res=(res+(d[i]+1)*p[i])%mod;
        sum=(sum+(c[i]+1)*p[i])%mod;
        mus=(mus+((c[i]^1)+1)*p[i])%mod;
    }
    for(int k=1,i=n;i>=1;k++,i--)
    {
        if(res==sum||res==mus) vis[k]++;
        sum=((sum-(c[i]+1)*p[n])%mod*p[1]%mod+(c[i]+1)*p[1])%mod;
        mus=((mus-((c[i]^1)+1)*p[n])%mod*p[1]%mod+((c[i]^1)+1)*p[1])%mod;
        sum=(sum+mod)%mod;
        mus=(mus+mod)%mod;
    }
}
int main()
{
    p[0]=1;
    for(int i=1;i<N;i++) p[i]=p[i-1]*3%mod;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
        scanf("%d",&b[i]);
    for(int i=0;i<30;i++)
    {
        for(int j=1;j<=n;j++)
        {
            c[j]=a[j]>>i&1;
            d[j]=b[j]>>i&1;
        }
        solve();
    }
    for(int i=1;i<=n;i++)
        if(vis[i]==30)
    {
        printf("%d %d\n",i-1,a[i]^b[1]);
    }
}
