#include using namespace std; #ifdef LOCAL_DEBUG #include "LOCAL_DEBUG.hpp" #endif #define int long long const int INF = 1LL << 60; int a[4][4]; signed main(){ for(int i = 0; i < 4; i++){ for(int j = 0; j < 4; j++){ cin >> a[i][j]; a[i][j]--; } } vector used(16, false); int lim = 100; while(lim--){ int pos = -1; for(int i = 0; i < 4; i++){ for(int j = 0; j < 4; j++){ if(a[i][j] == -1){ pos = i * 4 + j; } } } if(used[pos]) break; int dx[4] = {1,0,-1,0}, dy[4] = {0,-1,0,1}; for(int i = 0; i < 4; i++){ int ny = pos/4 + dy[i]; int nx = pos%4 + dx[i]; if(ny < 0 || 4 <= ny || nx < 0 || 4 <= nx) continue; if(a[ny][nx] == pos){ used[pos] = true; swap(a[ny][nx], a[pos/4][pos%4]); break; } } } bool judge = true; for(int i = 0; i < 4; i++){ for(int j = 0; j < 4; j++){ if(i == 3 && j == 3) continue; if(a[i][j] != i * 4 + j) judge = false; } } cout << (judge ? "Yes" : "No") << endl; return 0; }