def say(a,b):
    print(a,b)

def read():
    return int(input())

squares = []
i = 0
while i**2 <= 2*10**12:
    squares.append(i**2)
    i+=1

def is_square(y):
    m = len(squares)
    a,b = 0,m-1
    while b-a > 0:
        c = (a+b)//2
        if squares[c] >= y:
            b = c
        else:
            a = c + 1
    if y == squares[a]:
        return a
    else:
        return -1

n = int(input())
for _ in range(n):
    say(0,0)
    d = read()

    possible = []
    x = 0
    while x <= 10**6 and x**2 <= d:
        if is_square(d - x**2) >= 0:
            y = is_square(d - x**2)
            if y <= 10**6:
                possible.append((x,y))
        x += 1

    for x,y in possible:
        say(x,y)
        d = read()
        if d == 0:
            break