
object Main extends App {

  import scala.io.StdIn._
  f
  def f: Unit = {
    val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
    if (n == 0 && m == 0) return
    val taro = Array.tabulate(n) { _ ⇒ readLine.trim.toInt }.sorted
    val hanako = Array.tabulate(m) { _ ⇒ readLine.trim.toInt }.sorted
    val taroSum = taro.sum
    val hanakoSum = hanako.sum
    val sum = taroSum + hanakoSum
    if (sum % 2 == 1) println(-1)
    else {
      taro.find(t ⇒ hanako.find(h ⇒ taroSum - t + h == hanakoSum + t - h).isDefined) match {
        case Some(t) ⇒
          println(s"$t ${hanako.find(h ⇒ taroSum - t + h == hanakoSum + t - h).get}")
        case None ⇒ println(-1)
      }
    }
    f
  }
}

