#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n;
int a[N], b[N];
int c[N], d[N];
int p[3*N];
int pi[3*N];
int A[N];
bool test(int n, int k, int x){
    for (int i = 0; i < n; i++){
        A[i] = a[i]^x;
        printf("test %d %d\n",A[i],b[(i+k)%n]);
        //assert(A[i] == b[(i+k)%n]);
        if (A[i] != b[(i+k)%n]) return false;
    }
    return true;
}
int main(){
    int n;
    scanf("%d",&n);
    for (int i = 0; i < n; i++) scanf("%d",&a[i]);
    for (int i = 0; i < n; i++) scanf("%d",&b[i]);
    for (int i = 0; i < n; i++) c[i] = a[i]^a[(i+1)%n];
    for (int i = 0; i < n; i++) d[i] = b[i]^b[(i+1)%n];
    for (int i = 0; i < n; i++) p[i] = c[i];
    p[n] = -1;
    for (int i = 0; i < n; i++) p[i+n+1] = p[i+2*n+1] = d[i];
    for (int i = 1; i <= 3*n; i++){
        int j = pi[i-1];
        while (j > 0 && p[i] != p[j])
            j = pi[j-1];
        if (p[i] == p[j])
            j++;
        pi[i] = j;
    }
    for (int i = 3*n; i > 2*n; i--){
        if (pi[i] == n){
            int k = (n-i%n)%n;
            int x = b[0]^a[k];
            printf("%d %d\n",k,x);
        }
    }

}
