#include using namespace std; int main(){ int t,n,m,k; cin>>t; while(cin>>n>>m>>k) cout<<(k%m