program Check;

{$APPTYPE CONSOLE}

uses
  TestLib, SysUtils;

const
  maxn=100000;

var
  s, sa, sgn: string;
  n, i, k, res: integer;

begin
  s:= trim(ouf.ReadString);
  if (s<>'NO') and (s<>'YES') then quit(_PE,Format('YES/NO expected, but [%s] found',[s]));
  sa:= trim(ans.ReadString);
  if sa<>s then quit(_WA,Format('[%s] expected, but [%s] found',[sa,s]));

  n:= inf.ReadLongint; inf.NextLine;

  if sa='NO' then begin
    if not ouf.SeekEof then quit(_PE,'Extra characters in output file.');
    quit(_OK,Format('NO : n= %d, n mod 4 = %d',[n,n mod 4]));
  end;

  res:= 0;
  for i:=1 to n do begin
    sgn:= trim(ouf.ReadString);
    if (sgn<>'+') and (sgn<>'-') then quit(_PE,Format('+/- expected, but [%s] found',[sgn]));
    k:= inf.ReadLongint; inf.NextLine;
    if sgn='+' then inc(res,k)
    else dec(res,k);
  end;

  if not ouf.SeekEof then quit(_PE,'Extra characters in output file.');
  
  if res<>0 then quit(_WA,Format('Sequence should sum to 0, but output=%d',[res]));
  quit(_OK,Format('YES : n= %d, n mod 4 = %d',[n,n mod 4]));
end.
