#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, c, o = 1;
  cin >> n >> c;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    int arr[4] = {a, b, 7 - a, 7 - b};
    if (i == 0)
      continue;
    else if (i > 0 && count(arr, arr + 4, c) == 0)
      o++;
  }
  (o == n) ? cout << "YES"
                  << "\n"
           : cout << "NO"
                  << "\n";
  return 0;
}
