#!/usr/bin/env python3
# https://www.codechef.com/JAN20A/problems/DYNAMO
for _ in range(int(input())):
    n = int(input())
    a = int(input())
    p = 10**n
    s = 2*p+a
    print(2*p+a)
    b = int(input())
    print(p-b)
    d = int(input())
    print(p-d)
    r = int(input())
    if r == -1:
        quit()

c5508dba3d73f932d81cf85951d0031ba4aa6a8d
<mask token>

for _ in range(int(input())):
    n = int(input())
    a = int(input())
    p = 10 ** n
    s = 2 * p + a
    print(2 * p + a)
    b = int(input())
    print(p - b)
    d = int(input())
    print(p - d)
    r = int(input())
    if r == -1:
        quit()

#!/usr/bin/env python3
# https://www.codechef.com/JAN20A/problems/DYNAMO
for _ in range(int(input())):
    n = int(input())
    a = int(input())
    p = 10**n
    s = 2*p+a
    print(2*p+a)
    b = int(input())
    print(p-b)
    d = int(input())
    print(p-d)
    r = int(input())
    if r == -1:
        quit()
