#include <bits/stdc++.h>
static const int INF = std::numeric_limits<int>::max();
int main() {
  int n, x, y;
  std::cin >> n >> x;
  y = 7 - x;
  bool ok = true;
  for (int i = 0; i < n; ++i) {
    int a, b;
    std::cin >> a >> b;
    if (a == x || a == y || b == x || b == y) {
      ok = false;
      break;
    }
  }
  std::cout << (ok ? "YES" : "NO") << std::endl;
}
