program cogs154;
var
i,j,n,k:longint;
tt,ans:longint;
s,t,r,w:longint;
begin
assign(input,'read.in'); reset(input);
assign(output,'read.out'); rewrite(output);
readln(n,k);
for i:=1 to k do
begin
ans:=0;
readln(s,t,r);
tt:=n div s;
if tt*s<n then inc(tt);
if tt mod t =0 then w:=tt div t-1 else w:=tt div t;
ans:=tt+w*r;
writeln(ans);
end;
close(input); close(output);
end.