t=int(input()) k=[] for i in range(t): x=int(input()) y=int(input()) while(x%y!=0): x=x+1 k.append(x) for i in range(len(k)): print(k[i])