#include <bits/stdc++.h>
using namespace std;
template <typename T>
string tostr(const T& t) {
  ostringstream os;
  os << t;
  return os.str();
}
int a[102], b[102];
vector<int> go(int x, int y) {
  vector<int> res;
  for (int i = 1; i <= 6; ++i) {
    if (i == x || i == 7 - x || i == y || i == 7 - y) continue;
    res.push_back(i);
  }
  return res;
}
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(false);
  int n, t;
  cin >> n >> t;
  for (int i = 0; i < n; ++i) cin >> a[i] >> b[i];
  for (int i = 1; i < n; ++i) {
    t = 7 - t;
    vector<int> m = go(a[i], b[i]);
    if (t != m[0] && t != m[1]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}
