@n=0..<>; @s=map[glob],<>; for(@s){ $d[$a=$_->[0]]^=1; $d[$b=$_->[1]]^=1; vec($e[$a],$b,1)=vec($e[$b],$a,1)=1; $h|=$e[$a]|$e[$b] } sub f{ my$e=$e[$_]; $_||${$_=1;vec($e,$_,1)&&f()for@n}for vec$g,$_,1 } f$_=$a; print$g ne$h|grep($_,@d)>2?NO:YES