T = int(input()) for i in range(T): N,M,K = map(int,input().split()) tmp = K%M a = M-N if a>tmp: print(tmp) else: print(0)