#include using namespace std; #define int long long int p,t; int qpow(int a,int b,const int &p){ int ans=1; while(b){ if(b&1) ans=ans*a%p; a=a*a%p; b>>=1; } return ans; } signed main(){ ios::sync_with_stdio(0); cin>>p>>t; while(t--){ int a,b,c,d; cin>>a>>b>>d; c=10; a=a%b; cout<