182032025-10-13 20:00:50algoproPingpongpypy3Time limit exceeded 50/100136ms25120 KiB
# UUID: 4fbd2331-aea5-4ee1-854e-ca8d14b7fc4f
import sys
input = sys.stdin.readline

def solve():
    a, b = [int(x) for x in input().split()]
    if a < 33 or b > 52 or a > 53: print(-1, -1)
    else:
        ma, mb = 3, 3
        if a > 33:
            ma += 1
            if a > 43: ma += 1
        if b > 30:
            mb += 1
            if b > 41: mb += 1
        cnt = max(ma, mb)
        if cnt == 3:
            print(11, min(10, b))
            b = max(0, b-10)
            print(11, min(10, b))
            b = max(0, b-10)
            print(11, min(10, b))
        elif cnt == 4:
            if b < 11: print(-1, -1)
            else:
                print(a-33, 11)
                b -= 11
                print(11, min(10, b))
                b = max(0, b-10)
                print(11, min(10, b))
                b = max(0, b-10)
                print(11, min(10, b))
        else:
            if b < 22: print(-1, -1)
            else:
                print(min(a-33, 10), 11)
                a -= min(a-33, 10)
                b -= 11
                print(a-33, 11)
                b -= 11
                print(11, min(10, b))
                b = max(0, b-10)
                print(11, min(10, b))
                b = max(0, b-10)
                print(11, min(10, b))


    

t = int(input())
while t > 0:
    t -= 1
    solve()
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted46ms19800 KiB
subtask220/20
2Accepted52ms21160 KiB
subtask330/30
3Accepted75ms21924 KiB
subtask40/50
4Time limit exceeded112ms24800 KiB
5Time limit exceeded126ms24252 KiB
6Time limit exceeded136ms25120 KiB