{$A+,B-,C+,D+,E-,F-,G+,H+,I+,J+,K-,L+,M-,N+,O+,P+,Q+,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}
{$MINSTACKSIZE $00004000}
{$MAXSTACKSIZE $00100000}
{$IMAGEBASE $00400000}
{$APPTYPE CONSOLE}

{Very stupid checker for problem: D. Governor}
{Written by avm}

uses
SysUtils, testlib;
const maxN = 10000;
      maxK = 1000000;
       eps = 1e-7;
type float = extended;
var w:array[1..maxN] of boolean;
    a,b:array[1..maxN] of float;
  s,msg:string;
  v,r1,r2 : float;
    i,n,KK : longint;

procedure WrongAnswer(s:string);
begin
if (Length(s) > 3) then
  if Copy(s,1,3) = 'PE:' then
    QUIT(_PE,s);
QUIT(_WA,s);
end;

function checkSolution(var f:InStream;var r:float):boolean;
var i,j:longint;
s:string;
begin
for i:=1 to n do w[i] := false;
r := KK;
for i:=1 to n do
  begin
  j := f.ReadLongint;
  s := f.ReadString;
  if s<>'' then
    begin
    msg := Format('PE:%d at line:tail = ',[i+1])+ s;
    Result := false;
    exit;
    end;
  if (j < 1) or (j > n) then
    begin
    msg := Format('illegal building number %d at line %d',[j,i+1]);
    Result := false;
    exit;
    end;
  if w[j] then
    begin
    msg := Format('building %d build 2 times at line %d',[j]);
    Result := false;
    exit;
    end;
  w[j] := true;
  r := r * a[j] - b[j];
  end;
if not f.seekeof then
  begin
  msg := 'PE:Something unexpected at the of file';
  Result := false;
  exit;
  end;
Result := true;
end;


begin
n := inf.ReadLongint;
if n > maxN then Quit(_FAIL,Format('Bad input: %d > %d',[n,maxN]));
KK := inf.ReadLongint;
if KK < 1 then Quit(_FAIL,Format('Bad input: K = %d < 1',[KK]));
if KK > maxK then Quit(_FAIL,Format('Bad input: K = %d > %d',[KK,maxK]));
s := inf.ReadString;
if s<>'' then Quit(_FAIL,'Bad input: first line tail='+s);
for i:=1 to n do
  begin
  a[i] := inf.ReadReal;
  b[i] := inf.ReadReal;
  end;
if not checkSolution(ans,r1) then Quit(_FAIL,'Jury error: ' + msg);
if not checkSolution(ouf,r2) then WrongAnswer(msg);
if abs(r1-r2) < eps then Quit(_OK,'');
if abs(r1-r2) < eps * (abs (r1) + abs (r2) + eps) then Quit(_OK,'');
if abs(r1) > 1 / eps then
  begin
  v := r2 / r1;
  if (1-eps < v) and (v < 1 + eps)
    then Quit(_OK,'');
  end;
if r1 < r2 then Quit(_FAIL,Format('Jury not optimal: Jury=%g Answer=%g',[r1,r2]));
if r1 > r2 then WrongAnswer(Format('Not optimal solution: Jury=%g Answer=%g',[r1,r2]));
end.
