#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

template <typename T = string>
class SuffixArray
{
public:
  static const int MAX_N = 400010;
  int n, k;
  T S;
  int rank_sa[MAX_N + 1];
  int tmp[MAX_N + 1];
  int sa[MAX_N];

  SuffixArray(T S_) : S(S_) {}

  //文字列Sの接尾辞配列を構築

  void construct_sa()
  {
    n = distance(S.begin(), S.end());

    //最初は1文字，ランクは文字コードにすればよい
    for (int i = 0; i <= n; ++i)
    {
      sa[i] = i;
      rank_sa[i] = i < n ? S[i] : -1;
    }

    //(rank_sa[i],rank_sa[i+k])と(rank_sa[j],rank_sa[j+k])を比較
    auto comp = [&](int i, int j) {
      if (rank_sa[i] != rank_sa[j])
        return rank_sa[i] < rank_sa[j];
      else
      {
        int ri = i + k <= n ? rank_sa[i + k] : -1;
        int rj = j + k <= n ? rank_sa[j + k] : -1;
        return ri < rj;
      }
    };

    //k文字についてソートされているところから，2k文字でソートする
    for (k = 1; k <= n; k *= 2)
    {
      //compare_sa csa(n, k, rank_sa);
      sort(sa, sa + n + 1, comp);

      //いったんtmpに次のランクを計算し，それからrank_saに移す
      tmp[sa[0]] = 0;
      for (int i = 1; i <= n; ++i)
      {
        tmp[sa[i]] = tmp[sa[i - 1]] + (comp(sa[i - 1], sa[i]) ? 1 : 0);
      }
      for (int i = 0; i <= n; ++i)
        rank_sa[i] = tmp[i];
    }
  }

  //SにTが含まれるかどうか

  bool contain(T t)
  {
    int a = 0, b = distance(S.begin(), S.end());
    while (b - a > 1)
    {
      int c = (a + b) / 2;
      //Sのsa[c]文字目から|T|文字をTと比較
      if (S.compare(sa[c], distance(t.begin(), t.end()), t) < 0)
        a = c;
      else
        b = c;
    }
    return S.compare(sa[b], distance(t.begin(), t.end()), t) == 0;
  }

  void match(T t, vector<int> &res)
  {
    int l, r;

    int lo = -1, hi = n + 1;
    while (hi - lo > 1)
    {
      int mi = (lo + hi) / 2;
      T temp;
      for (int i = sa[mi]; i < min(sa[mi] + (int)distance(t.begin(), t.end()), n); i++)
        temp.push_back(S[i]);
      if (t <= temp)
        hi = mi;
      else
        lo = mi;
    }
    l = hi;

    lo = -1, hi = n + 1;
    while (hi - lo > 1)
    {
      int mi = (lo + hi) / 2;
      T temp;
      for (int i = sa[mi]; i < min(sa[mi] + (int)distance(t.begin(), t.end()), n); i++)
        temp.push_back(S[i]);
      if (t < temp)
        hi = mi;
      else
        lo = mi;
    }
    r = hi;
    for (int i = l; i < r; i++)
      res.push_back(sa[i]);
    sort(res.begin(), res.end());
  }
};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);

  int n;
  cin >> n;
  vector<ll> a(n), b(n), c(2 * n - 1), d(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n)
  {
    c[i] = a[i] ^ a[(i + 1) % n];
    if (i != n - 1)
      c[i + n] = c[i];
  }
  rep(i, n) d[i] = b[i] ^ b[(i + 1) % n];

  SuffixArray<vector<ll>> SA(c);
  SA.construct_sa();
  vector<int> v;
  SA.match(d, v);
  for (auto k : v)
  {
    ll x = a[k] ^ b[0];
    cout << k << " " << x << endl;
  }
  return 0;
}


Measured memory_bytes: 24264