#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin>>T; while(T--){ int N,M,K; cin>>N>>M>>K; cout<<(M-N<=K%M?0:K%M)<<'\n'; } }