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 = true; int prevX = 0, prevY = 0; for (int a0 = 0; a0 < n; a0++) { string[] tokens_x = Console.ReadLine().Split(' '); int x = Convert.ToInt32(tokens_x[0]); int y = Convert.ToInt32(tokens_x[1]); if(a0 != 0) { if(a0 == 1) //choosing direction { if (x == prevX) horizontal = false; else if (y == prevY) horizontal = true; else { Console.WriteLine("NO"); return; } } else { if (horizontal) { if(prevY != y) { Console.WriteLine("NO"); return; } } else { if(prevX != x) { Console.WriteLine("NO"); return; } } } } prevX = x; prevY = y; } Console.WriteLine("YES"); } }