object Main extends App {
    val in = io.Source.stdin.getLines.map(_.split(" ").map(_.toInt))
    for (Array(n, m) <- in if n != 0 && m != 0) {
        val a = in.take(n).flatten.toList
        val b = in.take(m).flatten.toList
        a.sorted.find(b contains (b.sum - a.sum) / 2.0 + _) match {
            case Some(x) => println(x + " " + ((b.sum - a.sum) / 2 + x))
            case None => println(-1)
        }
    }
}