#include using namespace std; typedef long long ll; typedef vector VI; #define REP(i, n) for(int(i)=0;(i)<(n);++(i)) #define in(T,V) T V;cin>>V; const int MOD = int(1e9+7); const int dir[][2] = {{1,0},{0,1},{-1,0},{0,-1},{1,-1},{1,1},{-1,1},{-1,-1}}; int m[4][4]; int num(int x, int y){ return x==3&&y==3 ? 0 : y*4+x+1; } bool check(){ REP(y,4) REP(x,4) if(m[y][x] != num(x,y)) return false; return true; } int main(){ int zx = -1, zy = -1; REP(y,4) REP(x,4){ cin >> m[y][x]; if(m[y][x] == 0) zx = x, zy = y; } bool res = true; while(1){ if(check()) break; bool moveflag = false; REP(d,4){ int mx = zx + dir[d][0]; int my = zy + dir[d][1]; if(mx < 0 || mx >= 4 || my < 0 || my >= 4) continue; if(m[my][mx] == num(zx,zy)){ swap(m[my][mx], m[zy][zx]); zx = mx, zy = my; moveflag = true; break; } } if(!moveflag){ res = false; break; } } cout << (res ? "Yes" : "No") << endl; }