import scala.io.StdIn._
object Main extends App {
  val allSquares = (1 to 150).flatMap(height ⇒ (height + 1 to 150).map(width ⇒ Square(height, width))).sorted.toArray
  case class Square(h: Int, w: Int) extends Ordered[Square] {
    override def compare(that: Square): Int = {
      if (h * h + w * w == that.h * that.h + that.w * that.w) h.compare(that.h)
      else (h * h + w * w).compare(that.h * that.h + that.w * that.w)
    }

    override def toString: String = s"$h $w"
  }
  loop
  def loop: Unit = {
    val Array(h, w) = readLine.trim.split(' ').map(_.toInt)
    if (h == 0) return
    println(
      allSquares(upperBound(allSquares, Square(h, w)))
    )
    loop
  }

  def upperBound[T <: Ordered[T]](array: Array[T], target: T): Int = {
    var left = 0
    var right = array.length
    while(left < right){
      val mid = (left + right) / 2
      if (array(mid) <= target){
        left = mid + 1
      }else {
        right = mid
      }
    }
    right
  }
}

