#include "bits/stdc++.h" using namespace std; #define ll long long int #define rep(i,n) for( int i = 0; i < n; i++ ) #define rrep(i,n) for( int i = n; i >= 0; i-- ) #define REP(i,s,t) for( int i = s; i <= t; i++ ) #define RREP(i,s,t) for( int i = s; i >= t; i-- ) #define dump(x) cerr << #x << " = " << (x) << endl; #define INF 2000000000 #define mod 1000000007 #define INF2 1000000000000000000 vector> t = { { 1,2,3,4 },{ 5,6,7,8 },{ 9,10,11,12 },{ 13,14,15,0 } }; const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, -1, 0, 1 }; int main(void) { vector> a(4, vector(4)); int x, y; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { cin >> a[i][j]; if (a[i][j] == 0) x = i, y = j; } } bool flag = true; while (flag) { flag = false; for (int i = 0; i < 4; i++) { int xx = x + dx[i]; int yy = y + dy[i]; if (xx < 0 or xx >= 4 or yy < 0 or yy >= 4) continue; if (a[xx][yy] == t[x][y]) { swap(a[xx][yy], a[x][y]); x = xx, y = yy; flag = true; break; } //cout << "---------" << endl; //rep(i, 4) { // rep(j, 4) { // cout << a[i][j] << " "; // } // cout << endl; //} } } if (t == a) { cout << "Yes" << endl; } else { cout << "No" << endl; } return 0; return 0; }