import java.io.*; import java.util.*; public class Solution { private static InputReader in; private static PrintWriter out; public static void main(String[] args) throws IOException { in = new InputReader(System.in); out = new PrintWriter(System.out, true); int n = in.nextInt(); int a1 = in.nextInt(), a2 = in.nextInt(); boolean sx = true, sy = true; for (int i = 1; i < n; i++) { if (in.nextInt() != a1) sx = false; if (in.nextInt() != a2) sy = false; } if (sx || sy) out.println("YES"); else out.println("NO"); out.close(); System.exit(0); } static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer = null; } public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } } }