#include
#include
using namespace std;
int main(){
int s,t,r,n,k,tmp,tmp2;
scanf("%d%d",&n,&k);
while(k--){
scanf("%d%d%d",&s,&t,&r);
tmp = n/s;
if(tmp*s<n){
tmp += 1;
}
tmp2 = tmp/t;
if(tmp2*t==tmp){
tmp2-=1;
}
tmp = tmp+r*tmp2;
printf("%d\n",tmp);
}
return 0;
}