T = int(input()) for _ in range(T): N,M,K = map(int, input().split()) A0 = K%M if N