#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#define debug(...) \
  { cerr << "# " << __VA_ARGS__ << "\n"; }
#else
#define debug(...)
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
typedef unsigned long long ui64;
const i64 MOD = 119 << 23 | 1;
struct hashing {
  static constexpr int dimensions = 4;
  static constexpr int mod = (1u << 31) - 1;
  vector<vector<int>> hashes, p;
  static const vector<int> &get_bases() {
    static mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    static vector<int> bases;
    while (bases.size() < dimensions) {
      bases.emplace_back(uniform_int_distribution<int>((int)1e9, mod - 1)(rng));
    }
    return bases;
  }
  hashing(const vector<int> &s) : hashes(dimensions), p(dimensions) {
    int n = s.size();
    const vector<int> &bases = get_bases();
    for (int d = 0; d < dimensions; ++d) {
      hashes[d].resize(n + 1);
      p[d].resize(n + 1);
      p[d][0] = 1;
      long long base = bases[d];
      for (int i = 0; i < n; i++) {
        hashes[d][i + 1] = (hashes[d][i] * base + s[i]) % mod;
        p[d][i + 1] = p[d][i] * base % mod;
      }
    }
  }
  vector<int> get_hash(int i, int len) {
    vector<int> res;
    for (int d = 0; d < dimensions; ++d) {
      int hash = (int)((hashes[d][i + len] + (long long)hashes[d][i] * (mod - p[d][len])) % mod);
      res.emplace_back(hash);
    }
    return res;
  }
};
class {
 public:
  void solve() {
    int n;
    cin >> n;
    vector<int> a(n), b(n), sa(n), sb(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < n; ++i) cin >> b[i];
    for (int i = 0; i < n; ++i) {
      sa[i] = a[i] ^ a[(i + 1) % n];
      sb[i] = b[i] ^ b[(i + 1) % n];
      sa.push_back(sa[i]);
    }
    hashing A(sa), B(sb);
    for (int i = 0; i < n; ++i) {
      if (A.get_hash(i, n - 1) != B.get_hash(0, n - 1))
        continue;
      int v = a[i] ^ b[0];
      cout << i << ' ' << v << '\n';
    }
  }
} NSPACE;
int main() {
  FPEN;
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  NSPACE.solve();
}
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

vi LPS(vi pat)
{

    vi lps(sz(pat));
    lps[0]=0;
    ll len=0;
    ll i=1;
    while(i<sz(pat))
    {
        if(pat[i]==pat[len])
        {
            len++;
            lps[i]=len;
            i++;
        }
        else
        {
            if(len)
                len=lps[len-1];
            else
                lps[i]=0,i++;
        }
    }
    return lps;
}

vi KMP(vi pat,vi txt)
{
    vi lps=LPS(pat);
    vi ans;
    ll i=0,j=0;
    while(i<sz(txt))
    {
        if(pat[j]==txt[i]) i++,j++;
        if(j==sz(pat)) 
        {
            ans.pb(i-j+1);
            j=lps[j-1];
        }
        else if(i<sz(txt)&&txt[i]!=pat[j])
        {
            if(j)
                j=lps[j-1];
            else
                i++;
        }
    }
    return ans;
}
void solve()
{
    ll n,x;
    cin>>n;
    vi a;
    vi b;
    rep(i,0,n)
    {
        cin>>x;
        a.pb(x);
    }
    rep(i,0,n)
    {
        cin>>x;
        b.pb(x);
    }
    vi A,B;
    rep(i,0,n)
    {
        A.pb(a[i]^(a[(i+1)%n]));
        B.pb(b[i]^(b[(i+1)%n]));
    }
    rep(i,0,n-1)
    {
        A.pb(A[i]);
    }
    // cout<<KMP(B,A)<<endl;
    vi ans=KMP(B,A);
    for(auto u:ans)
    {
        cout<<u-1<<" "<<(a[u-1]^b[0])<<endl;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}