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