for i in range(int(input())): n,k = [int(i) for i in input().split()] dem = 0 for i in range(1,n*k): if i % n != 0: dem += 1 if dem == k : print(i) break