#include using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() template inline bool chmax(A &a, B b) { if (a inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; } typedef unsigned long long ull; typedef long long ll; typedef pair pii; typedef pair pll; const ll INF = 1ll<<29; const ll MOD = 1000000007; const double EPS = 1e-10; int main() { vector in; REP(i, 16) { int a; scanf("%d", &a); if (a == 0) in.push_back(15); else in.push_back(a - 1); } vector tmp; REP(i, 16) tmp.push_back(i); queue, int> > que; que.push(make_pair(tmp, 15)); bool ans = false; while (!que.empty()) { vector now = que.front().first; int pos = que.front().second; que.pop(); if (now == in) ans = true; int x = pos % 4, y = pos / 4; int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1}; REP(i, 4) { int nx = x + dx[i]; int ny = y + dy[i]; if (!(nx >= 0 && nx < 4 && ny >= 0 && ny < 4)) continue; int npos = ny * 4 + nx; int tx = now[npos] % 4, ty = now[npos] / 4; if (abs(tx - nx) + abs(ty - ny) == 1) continue; swap(now[pos], now[npos]); que.push(make_pair(now, npos)); swap(now[pos], now[npos]); } } puts(ans ? "Yes" : "No"); return 0; }