def dfs(arr, x, end):

    if x == end:
        result.append(money)
    for i in range(can):


for i in range(int(input())):
    money, n = input.split()
    money = list(map(int,money))
    result = []
    n = int(n)
    can = 1
    for i in range(n):
        can *= i
