#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair pi; typedef pair pl; typedef pair pls; int main() { int paz[6][6] = {0}; for (int i = 0; i < 5; i++) for (int j = 0; j < 5; j++) paz[i][j] = -1; for (int i = 1; i <= 4; i++) { for (int j = 1; j <= 4; j++) { cin >> paz[i][j]; } } int val = 1; for (int i = 1; i <= 4; i++) { for (int j = 1; j <= 4; j++) { if (paz[i][j] != val) { if ((paz[i - 1][j] == 0 || paz[i + 1][j] == 0 || paz[i][j - 1] == 0 || paz[i][j + 1] == 0) &&(paz[i - 1][j] == val || paz[i + 1][j] == val || paz[i][j - 1] == val || paz[i][j + 1] == val)) val++; else { cout << "No" << endl; return 0; } } else val++; if (val == 16)val = 0; } } cout << "Yes" << endl; return 0; }