using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static void Main(String[] args) { int n = Convert.ToInt32(Console.ReadLine()); bool horizontal = false; int axisValue = 0; string[] firstTokens = Console.ReadLine().Split(' '); int x = Convert.ToInt32(firstTokens[0]); int y = Convert.ToInt32(firstTokens[1]); string[] secTokens = Console.ReadLine().Split(' '); int secondX = Convert.ToInt32(secTokens[0]); int secondY = Convert.ToInt32(secTokens[1]); if(secondX == x) //vertical { horizontal = false; axisValue = x; } else if(secondY == y) //horizontal { horizontal = true; axisValue = y; } else goto invalid; for(int a0 = 2; a0 < n; a0++) { int[] point = Console.ReadLine().Split(' ').Select(s => Convert.ToInt32(s)).ToArray(); if((horizontal && point[1] != axisValue) || (!horizontal && point[0] != axisValue)) { goto invalid; } } Console.WriteLine("YES"); return; invalid: Console.WriteLine("NO"); } }