#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define fi first #define se second #define rep(i,n) for(int i = 0; i < (n); ++i) #define rrep(i,n) for(int i = 1; i <= (n); ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) #define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next) #define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++) #define rng(a) a.begin(),a.end() #define maxs(x,y) x = max(x,y) #define mins(x,y) x = min(x,y) #define pb push_back #define sz(x) (int)(x).size() #define pcnt __builtin_popcount #define snuke srand((unsigned)clock()+(unsigned)time(NULL)); #define df(x) int x = in() using namespace std; typedef long long int ll; typedef pair P; typedef vector vi; typedef vector vvi; inline int in() { int x; scanf("%d",&x); return x;} inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');} const int MX = 100005, INF = 1001001001; const ll LINF = 1e18; const double eps = 1e-10; const int di[] = {-1,0,1,0}, dj[] = {0,-1,0,1}; //^ //const int di[] = {-1,0,1,-1,1,-1,0,1}, dj[] = {-1,-1,-1,0,0,1,1,1}; int a[16]; int used[16]; bool dfs() { bool ok = true; rep(i,16) if (a[i] != (i+1)%16) ok = false; if (ok) return true; rep(p,16) if (!a[p]) { int i = p/4, j = p%4; used[p] = 1; rep(v,4) { int ni = i+di[v], nj = j+dj[v]; if (ni<0||nj<0||ni>=4||nj>=4) continue; int x = ni*4+nj; if (used[x]) continue; swap(a[x], a[p]); if (dfs()) return true; swap(a[x], a[p]); } used[p] = 0; } return false; } int main() { rep(i,16) cin >> a[i]; if (!dfs()) puts("No"); else puts("Yes"); return 0; }