import sys input = sys.stdin.readline T=int(input()) for t in range(T): N,M,K=map(int,input().split()) a0=K%M print(0 if M-N<=a0 else a0)