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()); int prev_x = -1; int prev_y = -1; bool same_x = true; bool same_y = true; 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(prev_x != -1) { if(x!= prev_x) same_x = false; if(y!= prev_y) same_y = false; } prev_x = x; prev_y = y; } Console.WriteLine(same_x || same_y?"YES":"NO"); } }