#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; const int dy[] = {0, 1, 0, -1}; const int dx[] = {1, 0, -1, 0}; bool solve(vector& a, bitset<16> used) { bool ok = true; for(int i=0; i<15; ++i){ if(a[i] != i + 1) ok = false; } if(ok) return true; int i = find(a.begin(), a.end(), 0) - a.begin(); int y = i / 4; int x = i % 4; for(int j=0; j<4; ++j){ int y2 = y + dy[j]; int x2 = x + dx[j]; if(y2 < 0 || 4 <= y2 || x2 < 0 || 4 <= x2) continue; int k = y2 * 4 + x2; if(used[a[k]]) continue; used[a[k]] = true; swap(a[i], a[k]); if(solve(a, used)) return true; swap(a[i], a[k]); used[a[k]] = false; } return false; } int main() { vector a(16); for(int i=0; i<16; ++i) cin >> a[i]; if(solve(a, 0)) cout << "Yes" << endl; else cout << "No" << endl; return 0; }