import java.util.*; public class Exercise95{ public static void main (String[] args){ Scanner sc = new Scanner(System.in); ArrayList a = new ArrayList(); for(int i = 1; i < 16; i++){ a.add(i); } a.add(0); ArrayList q = new ArrayList(); for(int i = 0; i < 16; i++){ q.add(sc.nextInt()); } while(q.indexOf(0) != 15){ int x = q.indexOf(0); if (x > 3) { if(q.get(x - 4) == a.get(x)){ int y = q.get(x - 4); q.set(x - 4, q.get(x)); q.set(x, y); continue; } } if(x % 4 != 3){ if(q.get(x + 1) == a.get(x)){ int y = q.get(x + 1); q.set(x + 1, q.get(x)); q.set(x, y); continue; } } if(x < 12){ if(q.get(x + 4) == a.get(x)){ int y = q.get(x + 4); q.set(x + 4, q.get(x)); q.set(x, y); continue; } } if (x % 4 != 0) { if(q.get(x - 1) == a.get(x)){ int y = q.get(x - 1); q.set(x - 1, q.get(x)); q.set(x, y); continue; } } break; } Integer[] ad = (Integer[])a.toArray(new Integer[16]); Integer[] qd = (Integer[])q.toArray(new Integer[16]); System.out.println((Arrays.equals(ad, qd))? "Yes" : "No"); } }