import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int[][]p = new int[4][4]; for(int i = 0; i < 4; i++) { for(int j = 0; j < 4; j++) { p[i][j] = scan.nextInt(); } } scan.close(); int r0 = 0; int c0 = 0; int cnt = 0; for(int i = 0; i < 4; i++) { for(int j = 0; j < 4; j++) { int t = p[i][j]; if(t == 0) { r0 = i; c0 = j; continue; } int l = len(t, i, j); if(l >= 2) { System.out.println("No"); System.exit(0); }else if(l == 1) { cnt ++; } } } int []dx = {1, -1, 0, 0}; int []dy = {0, 0, 1, -1}; boolean flag = true; // int[][]a = new int[4][4]; // for(int i = 0; i < 4; i++) { // for(int j = 0; j < 4; j++) { // a[i][j] = i * 4 + j + 1; // } // } // a[3][3] = 0; for(int i = 0; i < cnt; i++) { flag = true; for(int j = 0; j < 4; j++) { int nr = dx[j] + r0; int nc = dy[j] + c0; if(nr < 0 || nc < 0 || nr > 3 || nc > 3) { continue; } int k = p[nr][nc]; int n = num(r0, c0); //System.out.println(k + " " + n); if(n == k) { p[r0][c0] = k; r0 = nr; c0 = nc; flag = false; break; } } if(flag) { System.out.println("No"); System.exit(0); } } System.out.println("Yes"); } static int len(int n, int nr, int nc) { int r = n / 4; int c = n % 4; if(c == 0) { c = 3; r -= 1; }else { c -= 1; } int l = Math.abs(nr - r) + Math.abs(nc - c); return l; } static int num(int r, int c) { int n = 0; n = r * 4 + c + 1; return n; } }