import java.io.*; import java.util.*; import java.util.stream.*; public class Main { static int[][] goal = new int[4][4]; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int[][] org = new int[4][4]; int idx = 1; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { goal[i][j] = sc.nextInt(); org[i][j] = idx % 16; idx++; } } check(org, new boolean[16]); System.out.println("No"); } static boolean same(int[][] org) { for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (goal[i][j] != org[i][j]) { return false; } } } return true; } static void check(int[][] org, boolean[] used) { if (same(org)) { System.out.println("Yes"); System.exit(0); } int r = 0; int c = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (org[i][j] == 0) { r = i; c = j; break; } } } if (r > 0) { int v = org[r - 1][c]; if (!used[v]) { org[r - 1][c] = 0; org[r][c] = v; used[v] = true; check(org, used); used[v] = false; org[r - 1][c] = v; org[r][c] = 0; } } if (r < 3) { int v = org[r + 1][c]; if (!used[v]) { org[r + 1][c] = 0; org[r][c] = v; used[v] = true; check(org, used); used[v] = false; org[r + 1][c] = v; org[r][c] = 0; } } if (c > 0) { int v = org[r][c - 1]; if (!used[v]) { org[r][c - 1] = 0; org[r][c] = v; used[v] = true; check(org, used); used[v] = false; org[r][c - 1] = v; org[r][c] = 0; } } if (c < 3) { int v = org[r][c + 1]; if (!used[v]) { org[r][c + 1] = 0; org[r][c] = v; used[v] = true; check(org, used); used[v] = false; org[r][c + 1] = v; org[r][c] = 0; } } } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }