#include #define rep(i,n) for(int i = 0; i < (n); ++i) #define srep(i,s,t) for (int i = s; i < t; ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) using namespace std; typedef long long int ll; typedef pair P; #define yn {puts("Yes");}else{puts("No");} #define MAX_N 200005 int main() { int a[6][6]; rep(i,6){ if(i == 0 || i == 5){ rep(j,6)a[i][j] = 1001; }else{ a[i][0] = 1001; a[1][5] = 1001; srep(j,1,5){ cin >> a[i][j]; if(a[i][j] == 0)a[i][j] = 16; } } } int dx[4] = {-1, 1, 0, 0}; int dy[4] = {0, 0, -1, 1}; while(true){ int flag = 1; int x, y; srep(i,1,5){ srep(j,1,5){ if(a[i][j] != (i - 1) * 4 + j)flag = 0; if(a[i][j] == 16){ x = i; y = j; } } } if(flag){ cout << "Yes" << endl; return 0; } rep(i,4){ if(a[x+dx[i]][y+dy[i]] == (x - 1) * 4 + y){ flag = 1; swap(a[x][y], a[x+dx[i]][y+dy[i]]); break; } } if(flag == 0){ cout << "No" << endl; return 0; } } return 0; }