#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, d;
  cin >> n >> d;
  bool t = true;
  while (n--) {
    int a, b;
    cin >> a >> b;
    if (a == d || a == 7 - d || b == d || b == 7 - d) {
      t = false;
    }
  }
  if (t) {
    cout << "YES";
  } else
    cout << "NO";
}
