#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int i;
  while (cin >> n) {
    int top, bottom;
    cin >> top;
    int l[110], r[110];
    for (i = 0; i < n; i++) {
      cin >> l[i] >> r[i];
    }
    for (i = 0; i < n; i++) {
      bottom = 7 - top;
      if (bottom == l[i] || bottom == (7 - l[i]) || bottom == r[i] ||
          bottom == (7 - r[i])) {
        cout << "NO" << endl;
        break;
      }
    }
    if (i == n) cout << "YES" << endl;
  }
  return 0;
}
