#include #include #include #include #include #include #include #include #include #include static const int MOD = 1000000007; using ll = int64_t; using u32 = uint32_t; using namespace std; template constexpr T INF = ::numeric_limits::max()/32*15+208; int main() { int v[4][4], swapped[4][4]; int y = 0, x = 0; for (int i = 0; i < 4; ++i) { for (int j = 0; j < 4; ++j) { cin >> v[i][j]; swapped[i][j] = 0; if(v[i][j] == 0){ y = i, x = j; } } } auto f = [&](int x){ return 0 <= x && x <= 3; }; int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}; while(true){ int y2 = y, x2 = x; for (int i = 0; i < 4; ++i) { if(f(y+dy[i]) && f(x+dx[i])){ if(v[y+dy[i]][x+dx[i]] == 4*y+x+1 && !swapped[y+dy[i]][x+dx[i]]) { y2 += dy[i], x2 += dx[i]; swapped[y2][x2] = 1; break; } } } if(y2 == y && x2 == x) break; swap(v[y][x], v[y2][x2]); y = y2; x = x2; } for (int i = 0; i < 4; ++i) { for (int j = 0; j < 4; ++j) { if((i != 3 || j != 3) && v[i][j] != 4*i+j+1){ puts("No"); return 0; } } } puts("Yes"); return 0; }