import java.util.Scanner

object KMP {
  // i 番目の直前 res(i) 文字が先頭の res(i) 文字と等しい
  def table(w: Array[Int]): Array[Option[Int]] = {
    val n = w.length
    val res = Array.fill[Option[Int]](n+1)(None)
    var i = 2
    for (i <- 2 to n) {
      res(i-1) match {
        case Some(l) => if (w(i-1) == w(l)) res(i) = Some(l+1)
                        else res(i) = None
        case None => if (w(i-1) == w(0)) res(i) = Some(1)
                     else res(i) = None
      }
    }
    res
  }
  def enumerate(s: Array[Int], w: Array[Int]): List[Int] = {
    var m = 0
    var i = 0
    var res = List[Int]()
    val t = table(w)
    while (m + i < s.length) {
      if (s(m+i) == w(i)) {
        i += 1
        if (i == w.length) {
          res = m :: res
          m = m + i - t(i).getOrElse(0)
          i = t(i).getOrElse(0)
        }
      } else {
        m = m + i - t(i).getOrElse(-1)
        i = t(i).getOrElse(0)
      }
    }
    res
  }
}

case class Input(a: Array[Int], b: Array[Int]) {
  def solved: Output = {
    val n = a.length
    val cs = Array.tabulate(n)(i => a(i) ^ a((i+1)%n))
    val ds = Array.tabulate(2*n)(i => b(i%n) ^ b((i+1)%n))
    val ks = KMP.enumerate(ds, cs).map(k => (n-k)%n)
    Output(ks.map(k => (k, a(k%n)^b(0))))
  }
}

object Input {
  def fromStdin(): Input = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    Input(Array.fill(n)(sc.nextInt), Array.fill(n)(sc.nextInt))
  }
}

case class Output(kxs: List[(Int, Int)]) {
  override def toString(): String = {
    kxs.foldLeft("")({ case (acc, (k, x)) => s"${acc}${k} ${x}\n" })
  }

  def print() = printf(this.toString())
}

object Main extends App {
  Input.fromStdin().solved.print()
}
