#include <bits/stdc++.h>
using namespace std;
int a, s, k, f = 0, i;
int main() {
  cin >> a >> s;
  for (i = 0; i < a * 2; i++) {
    cin >> k;
    if (k == s || k == 7 - s) {
      f = 1;
      break;
    }
  }
  if (f)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
}
