#include #include using namespace std; pair ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}}; int main(){ vector> A(4,vector(4)),B(4,vector(4)); int zerox,zeroy; int nw = 1; for(int i = 0; 4 > i; i++){ for(int j = 0; 4 > j; j++){ cin>>A[i][j]; B[i][j] = nw; nw++; if(A[i][j] == 0){ zerox = i; zeroy = j; } } } B[3][3] = 0; while(!(zerox == 3 && zeroy == 3)){ for(int i = 0; 4 > i; i++){ if(0 <= zerox+ar4[i].first && zerox+ar4[i].first < 4 && 0 <= zeroy+ar4[i].second && zeroy+ar4[i].second < 4 && A[zerox+ar4[i].first][zeroy+ar4[i].second] == B[zerox][zeroy]){ swap(A[zerox][zeroy],A[zerox+ar4[i].first][zeroy+ar4[i].second]); zerox+=ar4[i].first; zeroy+=ar4[i].second; continue; } } break; } for(int i = 0; 4 > i; i++){ for(int j = 0; 4 > j; j++){ if(A[i][j] != B[i][j]){ cout << "No" << endl; return 0; } } } cout << "Yes" << endl; }