#include <bits/stdc++.h>
using namespace std;

const int mul[2] = {233, 19260817};
const int mod[2] = {998244353, 1000000007};

#define pb push_back

int n;
vector <int> a, b, na, nb, pw[2], hsh[2];
int get(int l, int r, int k) {return (hsh[k][r] + mod[k] - 1LL * pw[k][r - l] * hsh[k][l] % mod[k]) % mod[k];}

int main() {
	ios :: sync_with_stdio(0);
	cin >> n;
	for (int i = 0; i < n; ++ i) {int x; cin >> x; a.pb(x);}
	for (int i = 0; i < n; ++ i) {int x; cin >> x; b.pb(x);}
	for (int i = 0; i < n; ++ i) na.pb(a[i] ^ a[(i + 1) % n]);
	for (int i = 0; i < n; ++ i) na.pb(na[i]);
	for (int i = 0; i < n; ++ i) nb.pb(b[i] ^ b[(i + 1) % n]);
	int hb[2];
	for (int k = 0; k < 2; ++ k) {
		pw[k].pb(1); for (int i = 1; i <= n * 2; ++ i) pw[k].pb(1LL * mul[k] * pw[k].back() % mod[k]);
		hsh[k].pb(0); for (int i = 0; i < n * 2; ++ i) hsh[k].pb((1LL * mul[k] * hsh[k].back() + na[i]) % mod[k]);
		hb[k] = 0; for (int i = 0; i < n - 1; ++ i) hb[k] = (1LL * mul[k] * hb[k] + nb[i]) % mod[k];
	}
	for (int i = 0; i < n; ++ i)
		if (get(i, i + n - 1, 0) == hb[0] && get(i, i + n - 1, 1) == hb[1] && na[i + n - 1] == nb[n - 1])
			cout << i << " " << (a[i] ^ b[0]) << "\n";
	return 0;
}
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

vector<int> mp(vector<int> s) {
  int n = s.size();
  vector<int> ret(n + 1);
  ret[0] = -1;
  int j = -1;
  rep(i, n) {
    while (j >= 0 && s[i] != s[j]) j = ret[j];
    ret[i + 1] = ++j;
  }
  return ret;
}

vector<int> kmp(vector<int> str, vector<int> word) {
  vector<int> table = mp(word), ret;
  int m = 0, i = 0, n = str.size();
  while (m + i < n) {
    if (word[i] == str[m + i]) {
      if (++i == (int)(word.size())) {
        ret.push_back(m);
        m = m + i - table[i];
        i = table[i];
      }
    }
    else {
      m = m + i - table[i];
      if (i > 0) i = table[i];
    }
  }
  return ret;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];

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

  vector<int> res = kmp(c, d);
  rep(i, res.size()) {
    int k = res[i];
    if (k >= n) break;
    int x = a[k] ^ b[0];
    cout << k << " " << x << endl;
  }


  
  return 0;
}