#include using namespace std; int T,N,M,K; main() { cin>>T; for(;T--;) { cin>>N>>M>>K; int a=K%M; int ni=M-a; cout<<(N