#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

ll min(ll a, ll b) {return a < b ? a : b;}
ll min(int a, ll b) {return a < b ? a : b;}
ll min(ll a, int b) {return a < b ? a : b;}
ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
ll max(int a, ll b) {return a > b ? a : b;}
ll max(ll a, int b) {return a > b ? a : b;}
ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
//#define int long long

const int MOD = 1e9 + 239;
const int Q = 1e6 + 3;
long long X;
int n;
int a[500000], b[500000];
int A[35][500000], B[35][500000], C[35][500000];
int hA[35][500000], hB[35][500000], hC[35][500000];

long long inq(long long a, long long b)
{
    if (b == 0) return 1;
    long long l = inq(a, b / 2);
    if (b % 2) return l * l % MOD * a % MOD;
    return l * l % MOD;
}

bool same1(int j, int l, int r)
{
    long long me = (hA[j][r] + MOD - (l > 0 ? hA[j][l - 1] * X % MOD: 0)) % MOD;
    return me == hB[j][n - 1];
}

bool same2(int j, int l, int r)
{
    long long me = (hC[j][r] + MOD - (l > 0 ? hC[j][l - 1] * X % MOD: 0)) % MOD;
    return me == hB[j][n - 1];
}

signed main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
    X = inq(Q, n);
    F(i, n) cin >> a[i];
    F(i, n) cin >> b[i];
    for (int j = 0; j < 30; j++)
    {
        for (int i = 0; i < n; i++)
        {
            if (a[i] & (1 << j)) A[j][i] = 1, A[j][i + n] = 1;
            else C[j][i] = 1, C[j][i + n] = 1;
        }
        for (int i = 0; i < n; i++)
        {
            if (b[i] & (1 << j)) B[j][i] = 1, B[j][i + n] = 1;
        }
    }
    for (int j = 0; j < 30; j++)
    {
        hA[j][0] = A[j][0];
        hB[j][0] = B[j][0];
        hC[j][0] = C[j][0];
        for (int i = 1; i < 2 * n; i++)
        {
            hA[j][i] = ((long long)hA[j][i - 1] * Q + A[j][i]) % MOD;
            hB[j][i] = ((long long)hB[j][i - 1] * Q + B[j][i]) % MOD;
            hC[j][i] = ((long long)hC[j][i - 1] * Q + C[j][i]) % MOD;
        }
    }
    for (int k = 0; k < n; k++)
    {
        int t = 1;
        int x = a[k] ^ b[0];
        for (int j = 0; j < 30; j++)
        {
            int s1 = same1(j, k, k + n - 1), s2 = same2(j, k, k + n - 1);
            if (s1 || s2) continue;
            t = 0;
        }
        if (t) cout << k << " " << x << "\n";
    }
}


Measured memory_bytes: 364416