import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int[][] x = new int[n][4]; for (int i = 0; i < n; i++) { String[] sa = br.readLine().split(" "); for (int j = 0; j < 4; j++) { x[i][j] = Integer.parseInt(sa[j]); } } br.close(); int[][] a = new int[3][]; a[0] = new int[]{2, 8}; a[1] = new int[]{3, 9}; a[2] = new int[]{7, 9}; for (int i = 0; i < n; i++) { for (int j = 0; j < a.length; j++) { if (x[i][0] == a[j][0] && x[i][1] == a[j][1]) { a[j][0] = x[i][2]; a[j][1] = x[i][3]; } } } if (a[0][0] == 5 && a[0][1] == 8 && a[1][0] == 4 && a[1][1] == 8 && a[2][0] == 6 && a[2][1] == 8) { System.out.println("YES"); } else { System.out.println("NO"); } } }