#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
int n, top, l[105], r[105];
void solve() {
  int sum = 21;
  for (int i = 0; i < n; i++) {
    top = 7 - top;
    bool t[7] = {0};
    t[l[i]] = 1;
    t[r[i]] = 1;
    t[7 - l[i]] = 1;
    t[7 - r[i]] = 1;
    bool ok = false;
    for (int j = 1; j <= 6; j++) {
      if (!t[j] && j == top) {
        ok = true;
      }
    }
    if (!ok) {
      cout << "NO" << endl;
      return;
    }
  }
  cout << "YES" << endl;
}
int main() {
  while (cin >> n) {
    cin >> top;
    for (int i = 0; i < n; i++) {
      cin >> l[i] >> r[i];
    }
    solve();
  }
}
