import java.util.*; import java.awt.geom.*; import java.io.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[][] map = {{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,0}}; int[][] target = new int[4][4]; for(int i = 0; i < 4; i++) { for(int j = 0; j < 4; j++) { target[i][j] = sc.nextInt(); } } int x = 3; int y = 3; boolean ok = true; boolean[] moved = new boolean[16]; while(true) { boolean check = true; for(int i = 0; i < 4; i++) { for(int j = 0; j < 4; j++) { if(target[i][j] != map[i][j]) check = false; } } if(check) break; int[] vx = {1,0,-1,0}; int[] vy = {0,1,0,-1}; check = true; for(int i = 0; i < 4; i++) { int tmpx = vx[i] + x; int tmpy = vy[i] + y; if(tmpx < 0 || tmpy < 0 || tmpx > 3 || tmpy > 3) continue; if(target[y][x] == map[tmpy][tmpx] && !moved[target[y][x]]) { moved[target[y][x]] = true; map[tmpy][tmpx] = 0; map[y][x] = target[y][x]; check = false; x = tmpx; y = tmpy; break; } } if(check) { ok = false; break; } } if(ok) System.out.println("Yes"); else System.out.println("No"); } }