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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INF = 2147483647;
const long long LINF = 1LL<<60;
const long long MOD = (1LL<<61)-1; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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; }

struct mint {
    long long x;
    mint(long long x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
    	return *this;
    }
    mint& operator*=(const mint a) {
    	(x *= a.x) %= MOD;
    	return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
    	if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
    	return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

int main(void){
    ll base = 3;
    int N; cin >> N;
    VI a(N), b(N); REP(i,N) cin >> a[i]; REP(i,N) cin >> b[i];
    vector<mint> Ha(30), Hra(30), Hb(30);
    vector<mint> p(N);
    p[0] = 1; REP(i,N-1) p[i+1] = p[i]*base;
    REP(i,30){
        REP(j,N) Ha[i] += p[j]*((a[j]>>i) & 1);
        REP(j,N) Hra[i] += p[j]*(((a[j]>>i) & 1)^1);
        REP(j,N) Hb[i] += p[j]*((b[j]>>i) & 1);
    }

    vector<P> ans;
    REP(k,N){
        REP(i,30){
            Ha[i] -= p[N-1]*((a[N-1-k]>>i) & 1);
            Ha[i] *= base;
            Ha[i] += (a[N-1-k]>>i) & 1;
            Hra[i] -= p[N-1]*(((a[N-1-k]>>i) & 1)^1);
            Hra[i] *= base;
            Hra[i] += ((a[N-1-k]>>i) & 1)^1;
        }
        int x = 0;
        bool flag = true;
        REP(i,30){
            if(Ha[i].x == Hb[i].x) continue;
            else if(Hra[i].x == Hb[i].x) x += 1<<i;
            else{
                flag = false;
                break;
            }
        }
        if(flag){
            ans.emplace_back(N-1-k, x);
        }
    }

    SORT(ans);
    REP(i,ans.size()) cout << ans[i].first << " " << ans[i].second << en;
    return 0;
}

Measured memory_bytes: 8304