t=int(input()) for i in range(t): n,m,k=map(int,input().split()) a0=k%m if m-n>a0: print(a0) else: print(0)