program OddAndEven;

{ MICHAL WALA - POLAND }

uses crt;

type
  TDrogi=array[1..300] of integer;
  PDrogi=^TDrogi;
  TDrogi2=array[1..300] of PDrogi;
  TMiasta=array[1..300] of boolean;
var
  LPol:TDrogi;
  Pol:TDrogi2;
  zr,x:TMiasta;
  n,i,j:integer;
  fn:string;
  we:text;
  rezult:boolean;

procedure init(var t:TMiasta);
var
  i:integer;
begin
  for i:=1 to n do t[i]:=false;
end;

procedure ZrobMiasto(var m,zr1:TMiasta; nm:integer; parz:boolean;
                         var nn,np:integer);
var
  i:integer;
  d:PDrogi;
begin
  if zr[nm]
    then
      begin
        if parz xor m[nm] then rezult:=true
      end
    else
      begin
        zr[nm]:=true;
        zr1[nm]:=true;
  	m[nm]:=parz;
        if parz then inc(np)
                else inc(nn);
	d:=Pol[nm];
        i:=1;
        while (i<=LPol[nm]) and not rezult do
          begin
    	    ZrobMiasto(m,zr1,d^[i], not parz, np,nn);
            inc(i);
          end;
      end;
end;

procedure zrob(m1:integer);
var
  m,zr1:TMiasta;
  np,i,nn:integer;
begin
  init(m);
  init(zr1);
  np:=0;
  nn:=0;
  ZrobMiasto(m,zr1,m1,true,np,nn);
  for i:=1 to n do
    if zr1[i] then x[i]:=(m[i]=(np>nn));
end;

begin
  clrscr;
  write('Enter file name : oddeven?.inp ');
  readln(fn);
  assign(we,fn); reset(we);
  readln(we,n);
  for i:=1 to n do
    begin
      LPol[i]:=0;
      new(pol[i]);
    end;
  while not eof(we) do
    begin
      readln(we,i,j);
      inc(LPol[i]);
      Pol[i]^[LPol[i]]:=j;
      inc(LPol[j]);
      Pol[j]^[LPol[j]]:=i;
    end;
  close(we);
  i:=1;
  init(zr);
  init(x);
  rezult:=false;
  while (i<=n) and not rezult do
    begin
      if not zr[i] then zrob(i);
      inc(i);
    end;
  if rezult
    then
      begin
        writeln('YES');
        writeln;
        writeln('Press ENTER to exit...');
        readln
      end
    else
      begin
  	writeln('NO');
        j:=0;
        for i:=1 to n do if x[i] then inc(j);
	writeln('X has ',j,' elements');
        write('X :');
        for i:=1 to n do if x[i] then write(' ',i);
        writeln;
        writeln('Press ENTER to exit...');
        readln
      end;
end.
