l = [[i**2+j**2,i,j] for j in range(1,151) for i in range(1,151) if i!=j and i<j]

l = sorted(l)

while True:

    h,w = map(int,input().split())

    if w==h==0: break

    i = l.index([w**2+h**2,h,w])+1

    print(*l[i][1:],sep=' ')

import bisect

l = [[i**2+j**2,i,j] for j in range(1,151) for i in range(1,151) if i!=j and i<j]

l.sort()

while True:

    h,w = list(map(int,input().split()))

    if w==h==0: break

    r = l[bisect.bisect_right(l,[w**2+h**2,h,w])]

    print((r[1],r[2]))
l = [
    [i**2 + j**2, i, j]
    for j in range(1, 151)
    for i in range(1, 151)
    if i != j and i < j
]
l = sorted(l)
while True:
    h, w = map(int, input().split())
    if w == h == 0:
        break
    i = l.index([w**2 + h**2, h, w]) + 1
    print(*l[i][1:], sep=" ")

import bisect

l = [
    [i**2 + j**2, i, j]
    for j in range(1, 151)
    for i in range(1, 151)
    if i != j and i < j
]
l.sort()
while True:
    h, w = list(map(int, input().split()))
    if w == h == 0:
        break
    r = l[bisect.bisect_right(l, [w**2 + h**2, h, w])]
    print((r[1], r[2]))

+import bisect + -l = sorted(l) +l.sort() -    h, w = map(int, input().split()) +    h, w = list(map(int, input().split())) -    i = l.index([w**2 + h**2, h, w]) + 1 -    print(*l[i][1:], sep=" ") +    r = l[bisect.bisect_right(l, [w**2 + h**2, h, w])] +    print((r[1], r[2]))