for _ in range(int(input())): m,x=map(int,input().split()) if m>=x: print(x) elif x%m==0: print(m) else: print(x%m)
注意x%m==0的情况的就行了