#include #define FOR(i,a,b) for(int i = (a); i < (b); ++i) #define REP(i,n) FOR(i,0,n) #define RREP(i,n) for(int i = (n) - 1; (i) >= 0; --i) #define SZ(n) (int)(n).size() #define ALL(n) (n).begin(), (n).end() #define MOD LL(1e9 + 7) #define INF 1000000 using namespace std; typedef long long LL; typedef vector VI; typedef pair PI; int a[4][4]; int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 }; bool bo[4][4]; int main() { REP(j, 4) { REP(i, 4) { cin >> a[j][i]; } } int z = 1; int cnt = 0; while (cnt != 15) { REP(j, 4) { REP(i, 4) { if (a[j][i] == 0) { REP(k, 4) { int ny = j + dy[k]; int nx = i + dx[k]; if (ny < 0 || nx < 0 || ny > 4 || nx > 4) continue; if (a[ny][nx] == z) { swap(a[j][i], a[ny][nx]); break; } } } z++; if (z == 16) z = 0; } } cnt++; } bool ans = true; z = 1; REP(j, 4) { REP(i, 4) { if (a[j][i] != z) ans = false; z++; if (z == 16) z = 0; } } if (ans) cout << "Yes" << endl; else cout << "No" << endl; return 0; }