#include using namespace std; int goal[4][4] = { {1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 0} }; int now[4][4]; int dy[] = {0, 0, 1, -1}; int dx[] = {1, -1, 0, 0}; bool slide(int &zy, int &zx){ for(int k=0;k<4;k++){ int ny = zy + dy[k]; int nx = zx + dx[k]; if(ny < 0 || nx < 0 || ny >= 4 || nx >= 4)continue; if(now[ny][nx] != goal[zy][zx])continue; swap(now[ny][nx], now[zy][zx]); zy = ny; zx = nx; return true; } return false; } bool last_check(){ for(int y=0;y<4;y++)for(int x=0;x<4;x++){ if(now[y][x] != goal[y][x])return false; } return true; } int main(){ int zy, zx; for(int y=0;y<4;y++)for(int x=0;x<4;x++)cin >> now[y][x]; for(int y=0;y<4;y++)for(int x=0;x<4;x++){ if(now[y][x] == 0){ zy = y; zx = x; } } while(slide(zy, zx)); cout << (last_check() ? "Yes" : "No") << endl; return 0; }