#include using namespace std; int main() { int T,N,M,K,A; cin>>T; while(cin>>N>>M>>K)cout<<(K%M