program pil_13_30(input,output);
type
  complex= record
    re, im : real
  end;
  coeff = record
    a,b,c : complex
  end;
  
var
  p : coeff;
  x, y : complex;
      
procedure inputcom(var a : complex);
begin
  read(a.re, a.im);
end;      

procedure value (var p : coeff; var x, y : complex);
var 
  sqrx : complex;
begin
  sqrx.re := sqr(x.re)-sqr(x.im);
  sqrx.im := 2*x.re*x.im;
  with p do begin
    y.re :=   a.re*sqrx.re-a.im*sqrx.im
            + b.re*   x.re-b.im*   x.im
            + c.re;
    y.im :=   a.re*sqrx.im+a.im*sqrx.re
            + b.re*   x.im+b.im*   x.re
            + c.im;
  end;
end;

begin
  Write('Input coefficients a, b, c : ');
  inputcom(p.a);
  inputcom(p.b);
  inputcom(p.c);
  Write('Input x : ');
  inputcom(x);
  value(p, x, y);
  Write('The result is : ', y.re:1:1);
  if y.im>0 then Write('+', y.im:1:1)
  else if y.im<0 then Write('-', y.im:1:1);
  WriteLn;
end.
