fork download
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. bool possible(true);
  6. int n, x, a, b;
  7. cin >> n >> x;
  8. while (n--)
  9. {
  10. cin >> a >> b;
  11. if (x == a || x == b || x == 7 - a || x == 7 - b)
  12. {
  13. possible = false;
  14. }
  15. x = 7 - x;
  16. }
  17. cout << (possible ? "YES" : "NO") << endl;
  18. return 0;
  19. }
Success #stdin #stdout 0s 3344KB
stdin
4

3

5 6

1 5

5 1

1 5
stdout
YES