Under construction

Still being built. Things may change

Integer Rectangles

Time limit1sMemory limit128 MB

Summary
Find the smallest wide integer rectangle larger than the given one when ordered by diagonal length and then height.
Level

Easy3 of 10

Topics
Brute force, Math
Solved
No attempts yet

Problem

A rectangle whose height hh and width ww are both natural numbers is called an integer rectangle. An integer rectangle whose width is larger than its height (w>hw > h) is called a wide integer rectangle.

Two wide integer rectangles are compared in this order.

  1. The one with the shorter diagonal is smaller.
  2. If the two diagonals have the same length, the one with the smaller height is smaller.

Given one wide integer rectangle, write a program that finds the smallest wide integer rectangle larger than it.

Input

The input consists of several test cases. There are at most 100 test cases. Each test case is one line containing the height hh and the width ww of a wide integer rectangle, separated by a space.

hh and ww are larger than 0 and at most 100, and ww is larger than hh.

The last line of the input contains two zeros.

Output

For each test case, print on one line the height and the width of the smallest wide integer rectangle larger than the given one, separated by a space. These values do not exceed 150.

Examples1

  1. Example 1

    Input
    1 2
    1 3
    2 3
    1 4
    2 4
    5 6
    1 8
    4 7
    98 100
    99 100
    0 0
    
    Expected output
    1 3
    2 3
    1 4
    2 4
    3 4
    1 8
    4 7
    2 8
    3 140
    89 109