$n=<>; for$i(1..$n){ ($r1,$c1,$r2,$c2)=glob<>; push@{"$r1,$c1"},"$r2,$c2"; push@{"$r2,$c2"},"$r1,$c1"; $a{"$r1,$c1,$r2,$c2"}=1; $a{"$r2,$c2,$r1,$c1"}=1; } sub hoge1 { my($yx)=@_; @$yx=grep{$a{"$yx,$_"}}@$yx; if(@$yx==1){ $z=pop@$yx; $a{"$yx,$z"}=0; $a{"z,$yx"}=0; hoge1($z); } } for$y(1..100){ for$x(1..100){ hoge1("$y,$x"); } } sub hoge2 { my($yx)=@_; if(@$yx>2){ $f=1; } my@t=@$yx; @$yx=(); for(@t){ hoge2($_); } } for$y(1..100){ for$x(1..100){ hoge2("$y,$x"); } } print $f?NO:YES;