program shulie; var a:array[1..5]of integer; b,i,j,k:integer; begin readln(b); for i:=1 to b do for j:=1 to 4 do begin read(a[j]);readln; if a[2]-a[1]-(a[4]-a[3])=0 then begin a[5]:=a[4]+a[4]-a[3]; for k:=1 to 5 do write(a[k]); writeln; end else begin a[5]:=a[4]div a[3]*a[4]; for k:=1 to 5 do write(a[k]); writeln; end; end; readln; end.