Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

def suffix_array(s):
    n = len(s)
    cnt = [0] * n
    for i in range(n):
        cnt[s[i]] += 1
    for i in range(1, n):
        cnt[i] += cnt[i-1]
    p = [0] * n
    for i in range(n):
        cnt[s[i]] -= 1
        p[cnt[s[i]]] = i
    c = [0] * n
    cl = 0
    for i in range(1, n):
        if s[p[i]] != s[p[i-1]]:
            cl += 1
        c[p[i]] = cl

    pn = [0] * n
    cn = [0] * n
    h = 0
    while (1 << h) < n:
        for i in range(n):
            pn[i] = p[i] - (1 << h)
            if pn[i] < 0:
                pn[i] += n
        cnt = [0] * n
        for i in range(n):
            cnt[c[pn[i]]] += 1
        for i in range(1, n):
            cnt[i] += cnt[i-1]
        for i in range(n)[::-1]:
            cnt[c[pn[i]]] -= 1
            p[cnt[c[pn[i]]]] = pn[i]
        cn[p[0]] = 0
        cl = 0
        for i in range(1, n):
            cur = (c[p[i]], c[(p[i] + (1 << h)) % n])
            prev = (c[p[i-1]], c[(p[i-1] + (1 << h)) % n])
            if cur != prev:
                cl += 1
            cn[p[i]] = cl
        c, cn = cn, c
        h += 1
    return p


def bin_search(a, b, sa, lower):
    lb, ub = -1, N
    while ub - lb > 1:
        m = (lb + ub) // 2
        for i in range(N):
            j = (sa[m] + i) % N
            if a[i] < b[j]:
                ub = m
                break
            if a[i] > b[j]:
                lb = m
                break
        else:
            if lower:
                ub = m
            else:
                lb = m
    return ub

N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cnt = [0] * N
for i in range(30):
    c = [x >> i & 1 for x in a]
    d = [x >> i & 1 for x in b]
    sa = suffix_array(d)
    lb = bin_search(c, d, sa, True)
    ub = bin_search(c, d, sa, False)
    for j in range(lb, ub):
        cnt[(N - sa[j]) % N] += 1
    c = [1 - x for x in c]
    lb = bin_search(c, d, sa, True)
    ub = bin_search(c, d, sa, False)
    for j in range(lb, ub):
        cnt[(N - sa[j]) % N] += 1
for k in range(N):
    if cnt[k] == 30:
        x = a[k] ^ b[0]
        print(k, x)

Fixed submission:
from bisect import bisect_left
import sys
input = sys.stdin.readline

class Compress:

    def __init__(self, vs):
        self.xs = list(set(vs))
        self.xs.sort()

    def compress(self, x):
        return bisect_left(self.xs, x)

    def decompress(self, i):
        return self.xs[i]

def suffix_array(s):
    n = len(s)
    comp = Compress(s)
    t = [comp.compress(s[i]) for i in range(n)]
    cnt = [0] * n
    for i in range(n):
        cnt[t[i]] += 1
    for i in range(1, n):
        cnt[i] += cnt[i-1]
    p = [0] * n
    for i in range(n):
        cnt[t[i]] -= 1
        p[cnt[t[i]]] = i
    c = [0] * n
    cl = 0
    for i in range(1, n):
        if s[p[i]] != s[p[i-1]]:
            cl += 1
        c[p[i]] = cl

    pn = [0] * n
    cn = [0] * n
    h = 0
    while (1 << h) < n:
        for i in range(n):
            pn[i] = p[i] - (1 << h)
            if pn[i] < 0:
                pn[i] += n
        cnt = [0] * n
        for i in range(n):
            cnt[c[pn[i]]] += 1
        for i in range(1, n):
            cnt[i] += cnt[i-1]
        for i in range(n)[::-1]:
            cnt[c[pn[i]]] -= 1
            p[cnt[c[pn[i]]]] = pn[i]
        cn[p[0]] = 0
        cl = 0
        for i in range(1, n):
            cur = (c[p[i]], c[(p[i] + (1 << h)) % n])
            prev = (c[p[i-1]], c[(p[i-1] + (1 << h)) % n])
            if cur != prev:
                cl += 1
            cn[p[i]] = cl
        c, cn = cn, c
        h += 1
    return p


def bin_search(a, b, sa, lower):
    lb, ub = -1, N
    while ub - lb > 1:
        m = (lb + ub) // 2
        for i in range(N):
            j = (sa[m] + i) % N
            if a[i] < b[j]:
                ub = m
                break
            if a[i] > b[j]:
                lb = m
                break
        else:
            if lower:
                ub = m
            else:
                lb = m
    return ub

N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [a[i] ^ a[(i+1)%N] for i in range(N)]
d = [b[i] ^ b[(i+1)%N] for i in range(N)]
sa = suffix_array(d)
lb = bin_search(c, d, sa, True)
ub = bin_search(c, d, sa, False)
ans = []
for j in range(lb, ub):
    k = (N - sa[j]) % N
    x = a[k] ^ b[0]
    ans.append((k, x))
ans.sort()
for k, x in ans:
    print(k, x)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

class Suffix:
    def __init__(self):
        self.index = 0
        self.rank = [0, 0]

def suffix_array(s):
    n = len(s)
    suffixes = [Suffix() for _ in range(n)]
    for i in range(n):
        suffixes[i].index = i
        suffixes[i].rank = [s[i], s[(i+1) % n]]
    suffixes.sort(key=lambda x: x.rank)
    ind = [0] * n
    k = 2
    while k < n:
        for i in range(n):
            ind[suffixes[i].index] = i

        rank = -1
        prev_rank = (-1, -1)

        for i in range(n):
            if suffixes[i].rank != prev_rank:
                rank += 1
            prev_rank = suffixes[i].rank
            suffixes[i].rank = (rank, suffixes[ind[(suffixes[i].index + k) % n]].rank[0])

        suffixes.sort(key=lambda x: x.rank)
        k *= 2
    return [x.index for x in suffixes]

def lower_bound(a, b, sa):
    lb, ub = -1, N
    while ub - lb > 1:
        m = (lb + ub) // 2
        for i in range(N):
            j = (sa[m] + i) % N
            if a[i] < b[j]:
                ub = m
                break
            if a[i] > b[j]:
                lb = m
                break
        else:
            ub = m
    return ub

def upper_bound(a, b, sa):
    lb, ub = -1, N
    while ub - lb > 1:
        m = (lb + ub) // 2
        for i in range(N):
            j = (sa[m] + i) % N
            if a[i] < b[j]:
                ub = m
                break
            if a[i] > b[j]:
                lb = m
                break
        else:
            lb = m
    return ub

N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cnt = [0] * N
for i in range(30):
    c = [x >> i & 1 for x in a]
    d = [x >> i & 1 for x in b]
    sa = suffix_array(d)
    lb = lower_bound(c, d, sa)
    ub = upper_bound(c, d, sa)
    for j in range(lb, ub):
        cnt[(N - sa[j]) % N] += 1
    c = [1 - x for x in c]
    lb = lower_bound(c, d, sa)
    ub = upper_bound(c, d, sa)
    for j in range(lb, ub):
        cnt[(N - sa[j]) % N] += 1
for k in range(N):
    if cnt[k] == 30:
        x = a[k] ^ b[0]
        print(k, x)

Fixed submission:
from bisect import bisect_left
import sys
input = sys.stdin.readline

class Compress:

    def __init__(self, vs):
        self.xs = list(set(vs))
        self.xs.sort()

    def compress(self, x):
        return bisect_left(self.xs, x)

    def decompress(self, i):
        return self.xs[i]

def suffix_array(s):
    n = len(s)
    comp = Compress(s)
    t = [comp.compress(s[i]) for i in range(n)]
    cnt = [0] * n
    for i in range(n):
        cnt[t[i]] += 1
    for i in range(1, n):
        cnt[i] += cnt[i-1]
    p = [0] * n
    for i in range(n):
        cnt[t[i]] -= 1
        p[cnt[t[i]]] = i
    c = [0] * n
    cl = 0
    for i in range(1, n):
        if s[p[i]] != s[p[i-1]]:
            cl += 1
        c[p[i]] = cl

    pn = [0] * n
    cn = [0] * n
    h = 0
    while (1 << h) < n:
        for i in range(n):
            pn[i] = p[i] - (1 << h)
            if pn[i] < 0:
                pn[i] += n
        cnt = [0] * n
        for i in range(n):
            cnt[c[pn[i]]] += 1
        for i in range(1, n):
            cnt[i] += cnt[i-1]
        for i in range(n)[::-1]:
            cnt[c[pn[i]]] -= 1
            p[cnt[c[pn[i]]]] = pn[i]
        cn[p[0]] = 0
        cl = 0
        for i in range(1, n):
            cur = (c[p[i]], c[(p[i] + (1 << h)) % n])
            prev = (c[p[i-1]], c[(p[i-1] + (1 << h)) % n])
            if cur != prev:
                cl += 1
            cn[p[i]] = cl
        c, cn = cn, c
        h += 1
    return p


def bin_search(a, b, sa, lower):
    lb, ub = -1, N
    while ub - lb > 1:
        m = (lb + ub) // 2
        for i in range(N):
            j = (sa[m] + i) % N
            if a[i] < b[j]:
                ub = m
                break
            if a[i] > b[j]:
                lb = m
                break
        else:
            if lower:
                ub = m
            else:
                lb = m
    return ub

N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [a[i] ^ a[(i+1)%N] for i in range(N)]
d = [b[i] ^ b[(i+1)%N] for i in range(N)]
sa = suffix_array(d)
lb = bin_search(c, d, sa, True)
ub = bin_search(c, d, sa, False)
ans = []
for j in range(lb, ub):
    k = (N - sa[j]) % N
    x = a[k] ^ b[0]
    ans.append((k, x))
ans.sort()
for k, x in ans:
    print(k, x)