import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().run(); } void run() { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int[][] map = new int[9][9]; map[1][7] = 1; map[2][8] = 2; map[6][8] = 3; for (int i = 0; i < N; ++i) { int x0 = sc.nextInt(); int y0 = sc.nextInt(); int x1 = sc.nextInt(); int y1 = sc.nextInt(); --x0; --y0; --x1; --y1; map[x1][y1] = map[x0][y0]; map[x0][y0] = 0; } if (map[4][7] == 1 && map[3][7] == 2 && map[5][7] == 3) { System.out.println("YES"); } else { System.out.println("NO"); } } static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }