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