#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;

std::mt19937 engine(chrono::steady_clock::now().time_since_epoch().count());
class RollingHash
{
  using ull = unsigned long long;
  ll N;
  const ull MASK30 = (1UL << 30) - 1;
  const ull MASK31 = (1UL << 31) - 1;
  const ull MOD = (1UL << 61) - 1;
  const ull POSITIVIZER = MOD * ((1UL << 3) - 1);
  static ull Base;
  static vector<ll> powMemo;
  vector<ull> dat;
public:
  long long size() const { return N; }
  void init(){
    while(Base <= 129) Base = engine();
    if(powMemo.size() < N) {
      ll from = powMemo.size();
      powMemo.resize(N);
      powMemo[0] = 1;
      for (int i = from; i < N; i++) if(i != 0)
        powMemo[i] = CalcMod(Mul(powMemo[i - 1], Base));
    }
  }
  RollingHash(){}
  RollingHash(string s): N(s.size()), dat(s.size()+1)
  {
    init();
    for (int i = 0; i < N; i++)
      dat[i + 1] = CalcMod(Mul(dat[i], Base) + s[i]);
  }

  ull hash(int l, int r) const
  {
    return CalcMod(dat[r] + POSITIVIZER - Mul(dat[l], powMemo[r-l]));
  }

  bool match(int l1, int r1, int l2, int r2){
    return hash(l1, r1) == hash(l2, r2);
  }

  ull Mul(ull l, ull r) const
  {
    long long lu = l >> 31;
    long long ld = l & MASK31;
    long long ru = r >> 31;
    long long rd = r & MASK31;
    long long middleBit = ld * ru + lu * rd;
    return ((lu * ru) << 1) + ld * rd + ((middleBit & MASK30) << 31) + (middleBit >> 30);
  }

  ull CalcMod(ull val) const
  {
    val = (val & MOD) + (val >> 61);
    if (val > MOD) val -= MOD;
    return val;
  }
};
unsigned long long RollingHash::Base = engine();
vector<long long> RollingHash::powMemo = {};

vector<long long> kmp_like_search(const RollingHash &rh1, const RollingHash &rh2){
  // rh1(S) の substring であって rh2(T) と一致するものを探す
  // res: vector of index of substring
  ll a = rh1.size(), b = rh2.size();
  vector<long long> res;
  if(a < b) return res;
  for(ll i = 0; i + b <= a; i++){
    if(rh1.hash(i, i + b) == rh2.hash(0, b)) res.push_back(i);
  }
  return res;
}

void abc150_F(long long N, std::vector<long long> a, std::vector<long long> b){
  ll bit = 32;
  vvl ans(N);
  rep(bb, bit){
    rep(flip, 2){
      string S(N, ' '), T(N, ' ');
      rep(i, N){
        S[i] = char((((a[i] >> bb) & 1LL) ^ flip) + '0');
        T[i] = char((((b[i] >> bb) & 1LL)) + '0');
      }
      S += S.substr(0, N-1);
      auto idxs = kmp_like_search(RollingHash(S), RollingHash(T));
      for(auto idx: idxs){
        ans[idx].pb(flip << bb);
      }
    }
  }
  rep(i,N){
    if(ans[i].size() == bit){
      ll x = 0;
      rep(bb, bit) x ^= ans[i][bb];
      cout << i << " " << x << endl;
    }
  }
}

int main(){
  std::cout << std::fixed << std::setprecision(15);
  long long N;
  scanf("%lld",&N);
  std::vector<long long> a(N-1-0+1);
  for(int i = 0 ; i < N-1-0+1 ; i++){
    scanf("%lld",&a[i]);
  }
  std::vector<long long> b(N-1-0+1);
  for(int i = 0 ; i < N-1-0+1 ; i++){
    scanf("%lld",&b[i]);
  }
  abc150_F(N, std::move(a), std::move(b));
  return 0;
}


Measured memory_bytes: 75468