import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

private fun solve() {
    val n = nextInt()
    val a = Array(n) { nextInt() }
    val b = Array(n) { nextInt() }
    val aa = Array(n) { a[it] xor a[(it + 1) % n] }
    val bb = Array(n) { b[it] xor b[(it + 1) % n] }
    val s = Array(3 * n + 1) { -1 }
    for (i in 0 until n) {
        s[i] = bb[i]
        s[n + 1 + i] = aa[i]
        s[2 * n + 1 + i] = aa[i]
    }
    val pi = Array(s.size) { 0 }
    for (i in 1 until pi.size - 1) {
        var j = pi[i - 1]
        while (j > 0 && s[i] != s[j]) {
            j = pi[j - 1]
        }
        if (s[i] == s[j]) ++j
        pi[i] = j
        if (j == n && i > 2 * n - 1) {
            val k = i % n
            val x = a[k] xor b[0]
            println("$k $x")
        }
    }
}

fun main(args: Array<String>) {
    solve()
    out.close()
}

private var br = BufferedReader(InputStreamReader(System.`in`))
private var st: StringTokenizer? = null
private var out = PrintWriter(System.out)

@Throws(IOException::class)
private fun next(): String {
    while (st == null || !st!!.hasMoreTokens()) {
        st = StringTokenizer(br.readLine())
    }
    return st!!.nextToken()
}

@Throws(IOException::class)
private fun nextInt(): Int {
    return next().toInt()
}

@Throws(IOException::class)
private fun nextLong(): Long {
    return next().toLong()
}
