import java.util.Scanner; public class Main_yukicoder228 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); a = new int[4][4]; int sx = 0; int sy = 0; g = new boolean[4][4]; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { a[i][j] = sc.nextInt(); if (a[i][j] == 0) { sx = j; sy = i; } if (a[i][j] == i * 4 + j + 1) { g[i][j] = true; } } } g[sy][sx] = true; dfs(sx, sy); boolean ret = true; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (!g[i][j]) { ret = false; } } } if (ret) { System.out.println("Yes"); } else { System.out.println("No"); } sc.close(); } static int[][] a; static boolean[][] g; static int[] dx = {1, -1, 0, 0}; static int[] dy = {0, 0, 1, -1}; private static void dfs(int sx, int sy) { for (int i = 0; i < 4; i++) { int tmpx = sx + dx[i]; int tmpy = sy + dy[i]; if (tmpx >= 0 && tmpx < 4 && tmpy >= 0 && tmpy < 4) { if (a[tmpy][tmpx] == sy * 4 + sx + 1) { g[tmpy][tmpx] = true; dfs(tmpx, tmpy); break; } } } } }