def solve(): N,M,K = map(int,input().split()) x = K % M if x // (M - N): print(0) else: print(x) T = int(input()) for _ in range(T): solve()