#!/usr/bin/perl $n = ; chomp $n; my $hor; my $ver; my $sid; my $msg = 'YES'; for my $a0 (0..$n-1){ $x_temp = ; @x_arr = split / /,$x_temp; $x = $x_arr[0]; chomp $x; $y = $x_arr[1]; chomp $y; if($a0 == 0) { $ver = $x; $hor = $y; } elsif ($a0 == 1) { if ($ver == $x) { $sid = 'ver'; } elsif ($hor == $y) { $sid = 'hor'; } else { $msg = 'NO'; last; } } if($sid eq 'ver') { if ($ver != $x) { $msg = 'NO'; last; } } elsif ($sid eq 'hor') { if($hor != $y) { $msg = 'NO'; last; } } } print "$msg\n";