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