#include using namespace std; int a[4][4]; int dy[] = {-1, 0, 0, 1}; int dx[] = {0, -1, 1, 0}; int y, x; int main(void) { for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { cin >> a[i][j]; if (a[i][j]) continue; a[i][j] = 16; y = i, x = j; } } while (true) { bool update = false; for (int i = 0; i < 4; i++) { int ny = y + dy[i], nx = x + dx[i]; if (ny >= 0 && ny < 4 && nx >= 0 && nx < 4) { if (a[ny][nx] == y * 4 + x + 1) { swap(a[y][x], a[ny][nx]); y = ny; x = nx; update = true; break; } } } if (!update) break; } bool yes = true; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { yes &= (a[i][j] == i * 4 + j + 1); } } cout << (yes ? "Yes" : "No") << endl; return 0; }