package no228; import java.util.Scanner; public class Main { public static void main(String[] args) { int[] di = {0,-1,0,1}; int[] dj = {1,0,-1,0}; Scanner sc = new Scanner(System.in); int[][] map = new int[4][4]; boolean[][] moved = new boolean[4][4]; int bi = 0, bj = 0; for(int i=0;i<4;i++) { for(int j=0;j<4;j++) { map[i][j] = sc.nextInt(); if (map[i][j] == 0) { bi = i; bj = j; } } } while(true) { boolean update = false; for(int k=0;k<4;k++) { int ni = bi + di[k]; int nj = bj + dj[k]; if (ni < 0 || ni >= 4 || nj < 0 || nj >= 4) { continue; } if (!moved[ni][nj] && map[ni][nj] == (bi * 4 + bj + 1)) { map[bi][bj] = bi * 4 + bj + 1; map[ni][nj] = 0; moved[bi][bj] = true; bi = ni; bj = nj; update = true; break; } } if (!update) { break; } } boolean ans = true; for(int i=0;i<4;i++) { for(int j=0;j<4;j++) { if (map[i][j] != (i * 4 + j + 1) % 16) { ans = false; } } } System.out.println(ans ? "Yes" : "No"); } }