print<>*grep({/ /,$ $`{$a[$'-1]}=${$'+0}{$a[$`-1]}=0for<>;(/^/$',@_=keys%{++$i})|1)?YES:NO