import java.util.Scanner; public class Main { static int dx[] = { 1, 0, 0, -1 }; static int dy[] = { 0, 1, -1, 0 }; public static void main(String[] args) { try (Scanner scan = new Scanner(System.in)) { int list[][] = new int[4][4]; boolean flag[][] = new boolean[4][4]; int zx = 0, zy = 0; for(int i=0; i<4; i++) { for(int j=0; j<4; j++) { list[i][j] = scan.nextInt(); if(list[i][j] == 0) { zx = j; zy = i; } } } boolean find = solve(list, flag, zx, zy); if(find) { System.out.println("Yes"); } else { System.out.println("No"); } } } static boolean check(int[][] list) { for(int i=0; i<4; i++) { for(int j=0; j<4; j++) { int value = i*4 + j + 1; if(i==3 && j==3) value = 0; if(list[i][j] != value) { return false; } } } return true; } static boolean solve(int [][] list, boolean flag[][], int zx, int zy) { if(check(list)) return true; boolean find = false; for(int i=0; i<4; i++) { int nextX = zx + dx[i]; int nextY = zy + dy[i]; if(nextX >= 0 && nextX <= 3 && nextY >= 0 && nextY <= 3 && !flag[nextY][nextX]) { int[][] nextList = new int[4][4];; for(int j=0; j<4; j++) { nextList[j] = list[j].clone(); } nextList[zy][zx] = list[nextY][nextX]; nextList[nextY][nextX] = 0; boolean[][] nextFlag = new boolean[4][4]; for(int j=0; j<4; j++) { nextFlag[j] = flag[j].clone(); } nextFlag[zy][zx] = true; find = solve(nextList, nextFlag, nextX, nextY); if(find) { break; } } } return find; } }