#include using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) int dy[] = {0, 0, 1, -1}; int dx[] = {1, -1, 0, 0}; bool check(vector > &s, vector > &t, vector > &moved) { if (s == t) return true; REP (y, 4) REP (x, 4) { if (s[y][x] == 0) { REP (k, 4) { int y2 = y + dy[k]; int x2 = x + dx[k]; if (y2 < 0 || y2 >= 4 || x2 < 0 || x2 >= 4) continue; if (moved[y2][x2]) continue; swap(s[y][x], s[y2][x2]); moved[y][x] = true; if (check(s, t, moved)) return true; moved[y][x] = false; swap(s[y][x], s[y2][x2]); } } } return false; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); vector > s { {1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 0}}; vector > t(4, vector(4)); REP (i, 4) REP (j, 4) cin >> t[i][j]; vector > moved(4, vector(4)); if (check(s, t, moved)) cout << "Yes" << endl; else cout << "No" << endl; return 0; }