#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() { int z = 1; REP(j, 4) { REP(i, 4) { cin >> a[j][i]; if (a[j][i] == z) bo[j][i] = true; z++; } } if (a[3][3] == 0) bo[3][3] = true; bool ans = true; z = 1; REP(j, 4) { REP(i, 4) { if (!bo[j][i]) { bool t = false; REP(k, 4) { int ny = i + dy[k]; int nx = j + dx[k]; if (ny < 0 || nx < 0 || ny > 3 || nx > 3) continue; if (a[ny][nx] == z) { t = true; break; } } ans = t; } z++; if (z == 16) z = 0; } } if (ans) cout << "Yes" << endl; else cout << "No" << endl; return 0; }