object Main {
  def solve(): Seq[List[Int]] = {
    val rectangles = scala.collection.mutable.Map[List[Int], Int]()
    for(r <- 1 to 150; c <- 1 to 150 if r < c) {
      rectangles += List(r, c) -> (r * r + c * c)
    }
    rectangles.toSeq.sortWith((p, q) =>
      if(p._2 == q._2) p._1(0) < q._1(0) else p._2 < q._2).map(p => p._1)
  }
  def main(args:Array[String]) = {
    val ans = solve
    val sc = new java.util.Scanner(System.in)
    var r = sc.nextInt
    var c = sc.nextInt
    while(r != 0 || c != 0) {
      println(ans(ans.indexOf(List(r, c)) + 1).mkString(" "))
      r = sc.nextInt
      c = sc.nextInt
    }
  }
}