#include <bits/stdc++.h>
using namespace std;
vector<int> l;
vector<int> r;
int main() {
  int n;
  int a;
  cin >> n;
  cin >> a;
  for (int i = 1; i <= n; i++) {
    int l1, r1;
    cin >> l1 >> r1;
    l.push_back(l1);
    r.push_back(r1);
  }
  for (int i = 0; i < l.size(); i++) {
    if (l[i] == r[i] || l[i] == a || r[i] == a || r[i] == 7 - a ||
        l[i] == 7 - a) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;
}
