#include <bits/stdc++.h>
using namespace std;
int n, x, a[101], b[101], t;
bool ok;
int main() {
  cin >> n >> x;
  t = 7 - x;
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i];
    if (x == a[i] || x == b[i] || 7 - x == a[i] || 7 - x == b[i]) ok = true;
    t = 7 - t;
  }
  if (ok)
    cout << "NO";
  else
    cout << "YES";
  return 0;
}
