#include using namespace std; struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star; #define all(c) (c).begin(), (c).end() #define rall(c) (c).rbegin(), (c).rend() #define vv(type, c, m, n, i) vector> c(m, vector(n, i)) #define mat(type, c, m, n) vector> c(m, vector(n));for(auto& r:c)for(auto& i:r)cin>>i; #define rep(i,a,n) for(int i=(a), i##_len=(n); ii##_len; --i) #define each(x,y) for(auto &(x):(y)) #define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__); template void Scan(T& t) { cin >> t; } templatevoid Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); } #define vec(type, c, n) vector c(n);for(auto& i:c) cin>>i; #define len(x) ((int)(x).size()) #define mp make_pair #define eb emplace_back #define em emplace #define pb pop_back #define fi first #define se second #define get(a, i) get(a) typedef long long ll; typedef long double ld; typedef vector vi; typedef vector vd; typedef vector vll; typedef vector vs; typedef vector vb; typedef pair pii; #define mini min_element #define maxi max_element #define sum(a, b) accumulate(a, b) #define chmax(a,b) if(ab)a=b template inline void print(T t){cout << t << "\n";} template inline void print(H h, T... t){cout << h << " ";print(t...);} bool solve() { vector a = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 0}}; vector v(4, vi(4)); map mip; map mpi; rep(i, 0, 4) rep(j, 0, 4){ cin >> v[i][j]; mip[v[i][j]] = mp(i, j); mpi[mp(i, j)] = v[i][j]; } int z; while (!(mip[0].fi == 3 && mip[0].se == 3)) { z = mip[0].fi * 4 + mip[0].se + 1; if (abs(mip[0].fi - mip[z].fi) + abs(mip[0].se - mip[z].se) > 1) break; swap(v[mip[0].fi][mip[0].se], v[mip[z].fi][mip[z].se]); swap(mip[0], mip[z]); } return a == v; } int main() { print(solve() ? "Yes" : "No"); return 0; }