#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<class T> vector<int> z_algorithm(const T& s) {
  vector<int> prefix(s.size());
  prefix[0] = s.size();
  int i = 1, j = 0;
  while (i < s.size()) {
    while (i + j < s.size() && s[j] == s[i + j]) ++j;
    prefix[i] = j;
    if (j == 0) { ++i; continue; }
    int k = 1;
    while (i + k < s.size() && k + prefix[k] < j) { prefix[i + k] = prefix[k]; ++k; }
    i += k; j -= k;
  }
  return prefix;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  vector<int> a2(n), b2(n);
  rep(i, n) {
    a2[i] = a[i]^a[(i+1)%n];
    b2[i] = b[i]^b[(i+1)%n];
  }
  vector<int> s = b2;
  rep(i, 2) rep(j, n)
    s.push_back(a2[j]);
  auto res = z_algorithm(s);
  for (int i = n; i < n*2; i++) {
    if (res[i] >= n) {
      int x = a[i-n]^b[0];
      cout << i-n << ' ' << x << '\n';
    }
  }
  return 0;
}