#include <bits/stdc++.h>
using namespace std;
int main() {
  int u, l, a[100], b[100], n;
  cin >> n >> u;
  l = 7 - u;
  for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
  for (int i = 0; i < n; i++) {
    if (a[i] == u || a[i] == l || b[i] == u || b[i] == l) {
      cout << "NO";
      return 0;
    } else
      continue;
  }
  cout << "YES";
  return 0;
}
