import java.util.LinkedList; import java.util.List; import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); List p = new LinkedList<>(); for (int a0 = 0; a0 < n; a0++) { int x = in.nextInt(); int y = in.nextInt(); p.add(new Point(x, y)); } boolean a = check(p); System.out.println(a ? "YES" : "NO"); } static boolean check(List points) { long dis = points .stream() .map(Point::getX) .distinct() .count(); if (dis < (points.size() - 2)) { return true; } dis = points .stream() .map(Point::getY) .distinct() .count(); return (dis < (points.size() - 2)); } } class Point { int x, y; Point(int x, int y) { this.x = x; this.y = y; } int getX() { return this.x; } int getY() { return this.y; } }