var s,o,p,a,b,c,y,e,d,i,u:integer;
begin
read(s);
while not eof do begin
readln(a,b,c,d);
y:=d div c;
p:=d mod c;
i:=c mod b;
u:=b mod a;
o:=d-c;
if (p=0) and (i=0) and (u=0) then
begin
e:=d*y;
writeln(a,' ',b,' ',c,' ',d,' ',e);
end
else
begin
e:=d+o;
writeln(a,' ',b,' ',c,' ',d,' ',e);
end;
end;
end.