#include <bits/stdc++.h>
int main() {
  int n, top;
  std::cin >> n >> top;
  int firstFace, secondFace;
  for (int i = 0; i < n; ++i) {
    scanf("%i %i", &firstFace, &secondFace);
    if (firstFace == top || secondFace == top || 7 - firstFace == top ||
        7 - secondFace == top) {
      std::cout << "NO\n";
      return 0;
    }
  }
  std::cout << "YES\n";
  return 0;
}
