#include<iostream>
#include<vector>
#include<set>
#include<map>

// zarray
template<typename S>
void zarray(S s, std::vector<int>& Z) {
  int N = s.size(), L, R = 0;
  Z.resize(N);
  for(int i = 1; i < N; ++i) {
    if(i > R) {
      L = R = i;
      while(R < N && s[R-L]==s[R]) ++R;
      Z[i] = R-- -L;
    } else if(Z[i-L] < R-i+1) {
      Z[i] = Z[i-L];
    } else {
      L = i;
      while(R < N && s[R-L] == s[R]) ++R;
      Z[i] = R-- -L;
    }
  }
}

int main() {
  int N; std::cin >> N;
  std::vector<int> a(N), b(N), c(N*3-2);
  for(int i = 0; i < N; ++i) std::cin >> a[i];
  for(int i = 0; i < N; ++i) std::cin >> b[i];
  for(int i = 0; i < N-1; ++i) c[i] = a[i]^a[i+1];
  c[N-1] = -1;
  for(int i = 0; i < N+N-2; ++i) c[N+i] = b[i%N]^b[(i+1)%N];

  std::vector<int> Z;
  zarray(c, Z);
  std::set<std::pair<int,int>> ans;
  for(int i = 0; i < N; ++i) if(Z[N+i]>=N-1) {
    ans.insert(std::make_pair((N-i)%N, a[0]^b[i]));
  }
  for(auto p: ans) std::cout << p.first << " " << p.second << "\n";
  return 0;
}
