#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
using ull = unsigned long long;
struct RollingHash{
    const ull mod = (1ll << 61) - 1, mask30 = (1ll << 30) - 1, mask31 = (1ll << 31) - 1;
    const ull base = 1009, positiviser = mod * 5;
    ull sn;
    vector<ull> hash, power;

    RollingHash(){}
    RollingHash(const vc<ll>& s){
        sn = s.size();
        hash.assign(sn + 1, 0);
        power.assign(sn + 1, 0);
        power[0] = 1;
        for (int i = 0;i < sn;i++){
            power[i + 1] = calc_mod(mul(power[i], base));
            hash[i + 1] = calc_mod(mul(hash[i], base) + s[i]);
        }
    }

    inline ull mul(ull a, ull b){
        ull au = a >> 31, ad = a & mask31;
        ull bu = b >> 31, bd = b & mask31;
        ull mid = ad * bu + au * bd;

        return ((au * bu) << 1) + ad * bd + ((mid & mask30) << 31) + (mid >> 30);
    }
    
    inline ull calc_mod(ull a){
        a = (a & mod) + (a >> 61);
        if (a >= mod) a -= mod;
        return a;
    }

    // S[b1:b1+len], S[b2:b2+len]が同じか判定   
    inline bool match(int begin1, int begin2, int len){
        ull h1 = calc_mod(hash[begin1 + len] + positiviser - mul(hash[begin1], power[len]));
        ull h2 = calc_mod(hash[begin2 + len] + positiviser - mul(hash[begin2], power[len]));

        return h1 == h2;
    }
    inline bool match(ull h1, ull h2){
        return h1 == h2;
    }

    // S[b:b+len]のハッシュを返す
    inline ull get(int begin, int len){
        return calc_mod(hash[begin + len] + positiviser - mul(hash[begin], power[len]));
    }
    
};

ll A[200000], B[200000];
int main() {
    init();
    ll N;
    cin >> N;
    vc<ll> H(3 * N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];

    rep(i, N - 1) H[i] = H[N + i] = A[i] ^ A[i + 1], H[2 * N + i] = B[i] ^ B[i + 1];
    H[N - 1] = A[0] ^ A[N - 1];

    RollingHash rh(H);

    vc<pair<ll, ll>> ans;
    rep(i,N){
        if (rh.match(2 * N, i, N - 1)) ans.eb(i, A[i] ^ B[0]);
    }

    repa(p, ans) cout << p.first << " " << p.second << '\n';
}

Measured memory_bytes: 23916