program cogs154;
var
n,m,i,a,b,c,t:longint;
procedure init;
begin
assign(input,'read.in');reset(input);
assign(output,'read.out');rewrite(output);
end;
procedure main;
begin
readln(n,m);
for i:=1 to m do
begin
readln(a,b,c);
if n mod a=0 then t:=n div a
else t:=trunc(n/a)+1;
if t mod b=0 then t:=t+(t div b-1)*c else t:=t+(t div b)*c;
writeln(t);
end;
end;
begin
init;
main;
end.