var
n,k,i,s,t,ans,r,v,a:longint;
begin
assign(input,'read.in');
assign(output,'read.out');
reset(input);rewrite(output);
read(n,k);
for i:=1 to k do
begin
read(s,t,r);
v:=s*t;
a:=n div v;
if (n mod v=0) and (a>0) then dec(a);
ans:=a*r;
if n mod s=0 then ans:=ans+(n div s) else ans:=1+ans+(n div s);
writeln(ans);
end;
close(input);close(output);
end.