1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
program kar; //Gra w karty, runda 1-A        21.11.2016
type Ti=longint; var t,n,m,i,j,tk:Ti; ch:char;
  Basum,Bisum:Ti;//sumy zagrożeń Ba->Bi i Ba<-Bi
  pary: array[1..200000] of record a,b:Ti; znak:char end;
  BaBi,BiBa: array[1..100000] of boolean; 

begin
  readln(t); //liczba zestawów
  for tk:=1 to t do
  begin
    readln(n,m); if m=0 then begin writeln('REMIS'); continue end; 
    Basum:=0; Bisum:=0;
    for i:=1 to n do begin BaBi[i]:=false; BiBa[i]:=false end;
    for j:=1 to m do with pary[j] do
    begin read(a); read(ch); read(znak); read(b);
      case znak of
      '>':if not BaBi[a] then 
          begin BaBi[a]:= true; Basum+=1 end;
      '<':if not BiBa[b] then 
          begin BiBa[b]:= true; Bisum+=1 end;
       end;//case
    end;//j
    if Basum=n then writeln('WYGRANA')
     else if Bisum=n then writeln('PRZEGRANA')
     else writeln('REMIS')
  end//t
end.