fun main(args: Array<String>) {
    val N = nextInt()
    val A = listOfInt()
    val B = listOfInt()
    var ans = 0L
    for (i in 0 until 29) {
        val mA = IntArray(N)
        val mB = IntArray(N)
        val mask = (1 shl i + 1) - 1
        for (j in 0 until N) {
            mA[j] = A[j] and mask
            mB[j] = B[j] and mask
        }
        mB.sort()
        var count = 0L
        val T = 1 shl i
        for (j in 0 until N) {
            val n1 = LowerBound(mB,     T - mA[j])
            val n2 = LowerBound(mB, 2 * T - mA[j])
            val n3 = LowerBound(mB, 3 * T - mA[j])
            count += (n2 - n1) + (N - n3)
        }
        ans = ans or ((count and 1) shl i)
    }
    println(ans)
}
fun LowerBound(arr: IntArray, v: Int): Int {
    var left = 0
    var right = arr.size - 1
    while (left <= right) {
        val center = (left + right) ushr 1
        if (v > arr[center]) left = center + 1
        else right = center - 1
    }
    return left
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt(d: Int = 0) = listOfString().map { it.toInt() + d }
fun listOfLong(d: Long = 0) = listOfString().map { it.toLong() + d }

