#include #include #include #include #define REP(i,n) for(int i=0; i<(int)(n); i++) using namespace std; inline int getInt(){ int s; scanf("%d", &s); return s; } vector > ans(4, vector(4)); vector > s(4, vector(4)); #define IN(x,s,g) ((x) >= (s) && (x) < (g)) #define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h))) const int _dx[] = {0,1,0,-1}; const int _dy[] = {-1,0,1,0}; bool check(int x, int y, int f){ if(ans == s) return true; REP(i,4){ const int xx = x + _dx[i]; const int yy = y + _dy[i]; if(ISIN(xx, yy, 4, 4)){ const int t = s[yy][xx]; if(f & (1 << t)){ swap(s[y][x], s[yy][xx]); if(check(xx, yy, f ^ (1 << t))) return true; swap(s[y][x], s[yy][xx]); } } } return false; } int main(){ REP(i,4) REP(j,4) ans[i][j] = getInt(); REP(i,4) REP(j,4) s[i][j] = i * 4 + j + 1; s[3][3] = 0; puts(check(3, 3, (1 << 16) - 1) ? "Yes" : "No"); return 0; }