t = int(input())
for _ in range(t):
    a = int(input())
    b = int(input())

    print(a//b)
    print(a%b)
    print()
t = int(input())
for _ in range(t):
    a = int(input())
    b = int(input())

    print(a//b)
    print(a%b)
    print()