uses
  testlib, sysutils;

function ending(x: longint): string;
begin
  x := x mod 100;
  if x div 10 = 1 then
    ending := 'th'
  else
    case x mod 10 of
      1: ending := 'st';
      2: ending := 'nd';
      3: ending := 'rd';
      else
        ending := 'th';
    end;
end;

var
  ja, pa, n: longint;
  v, p, vv: array[1..100000] of integer;
  s: int64;
  i, k: integer;

begin
  n := inf.readlongint;
  s := 0;
  for i := 1 to n do begin
    v[i] := inf.readlongint;
    p[i] := inf.readlongint;
    s := s + v[i];
  end;

  ja := ans.readlongint;
  pa := ouf.readlongint;

  k := ouf.readlongint;
  if (k < 1) or (k > n) then quit(_wa, 'Invalid number (not from 1..n): ' + inttostr(k));
  if (p[k] < 0) then quit(_wa, 'Tried to buy an honest party');

  for i := 1 to n do begin
    vv[i] := ouf.readlongint;
    if (vv[i] < 0) then quit(_wa, 'Negative number of people');
    s := s - vv[i];
  end;

  if (s <> 0) then quit(_wa, 'Number of people differs');


  s := p[k];
  for i := 1 to n do begin
    if (vv[i] < v[i]) then s := s + (v[i] - vv[i]);
  end;
  
  if (s <> pa) then quit(_wa, 'Wrong money calculations');

  for i := 1 to n do begin
    if (i <> k) and (vv[i] >= vv[k]) then quit(_wa, 'Party will not win');
  end;
  
  if (pa > ja) then quit(_wa, 'Not optimal solution');
  if (pa < ja) then quit(_fail, 'Jury''s solution is not optimal');

  quit(_ok, '');
end.
