#include #include #include using namespace std; #define RREP(i,s,e) for (i = e-1; i >= s; i--) #define rrep(i,n) RREP(i,0,n) #define REP(i,s,e) for (i = s; i < e; i++) #define rep(i,n) REP(i,0,n) #define INF 1e8 typedef long long ll; int main() { int i, j, x, y; bool found = true; int a[4][4]; rep (i,4) rep(j,4) { cin >> a[i][j]; if (a[i][j] == 0) { x = i; y = j; } } while (found) { found = false; int next[4] {-1, 0, 1, 0}; rep (i,4) { int nx = x + next[i]; int ny = y + next[(i+1)%4]; if (0 <= nx && nx < 4 && 0 <= ny && ny < 4 && a[nx][ny] == x*4+y+1) { a[x][y] = a[nx][ny]; a[nx][ny] = 0; x = nx; y = ny; found = true; } } } rep (i,4) rep (j,4) { if (a[i][j] != 0 && a[i][j] != i*4+j+1) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; }