import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI2(): return list(map(int,sys.stdin.readline().rstrip())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) def LS2(): return list(sys.stdin.readline().rstrip()) def min_primitive_root(p): # 素数pの最小の原始根 if p == 2: return 1 n = p-1 prime_list = [] # n の素因数 for i in range(2,int(n**.5)+1): if n % i == 0: prime_list.append(i) while n % i == 0: n //= i if n != 1: prime_list.append(n) a = 2 # 原始根の候補 n = p-1 while True: for prime in prime_list: if pow(a,n//prime,p) == 1: a += 1 break else: return a T = I() for _ in range(T): v,x = MI() p = x*v+1 r = min_primitive_root(p) ANS = [pow(r,v*i,p) for i in range(1,x+1)] ANS.sort() print(*ANS)