#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll a[N], b[N];
    REP(i, 0, N) {
        cin >> a[i];
    }
    REP(i, 0, N) {
        cin >> b[i];
    }
    ll aa[N], bb[N];
    REP(i, 0, N - 1) {
        aa[i] = a[i] ^ a[i + 1];
        bb[i] = b[i] ^ b[i + 1];
    }
    aa[N - 1] = a[N - 1] ^ a[0];
    bb[N - 1] = b[N - 1] ^ b[0];
    ll cyc = -1;
    REP(i, 1, N + 1) {
        if (N % i != 0) {
            continue;
        }
        bool ok = true;
        REP(j, 0, N) {
            if (aa[j] != aa[(j + i) % N]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            cyc = i;
            break;
        }
    }
    ll ansbase = -1;
    map<ll, ll> mpa;
    map<ll, ll> mpb;
    REP(i, 0, N) {
        if (mpa.count(aa[i]) == 0) {
            mpa[aa[i]] = 1;
        } else {
            mpa[aa[i]]++;
        }
        if (mpb.count(bb[i]) == 0) {
            mpb[bb[i]] = 1;
        } else {
            mpb[bb[i]]++;
        }
    }
    REP(i, 0, N) {
        if (mpa[aa[i]] != mpb[aa[i]]) {
            return 0;
        }
    }
    ll minnum = -1;
    ll minval = inf;
    REP(i, 0, N) {
        if (mpa[aa[i]] < minval) {
            minnum = i;
            minval = mpa[aa[i]];
        }
    }
    REP(i, 0, cyc) {
        bool ok = true;
        REP(j, 0, N) {
            if (aa[(minnum + j + i) % N] != bb[(minnum + j) % N]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            ansbase = i;
            break;
        }
    }
    if (ansbase != -1) {
        vector<plglg> ans;
        ll num = ansbase;
        while (num < N)
        {
            ll val = a[num] ^ b[0];
            ans.push_back(plglg(num, val));
            num += cyc;
        }
        REP(i, 0, ans.size())
        {
            cout << ans[i].first << " " << ans[i].second << endl;
        }
    }
}


Measured memory_bytes: 29824