#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, z, x, y;
  cin >> n;
  cin >> z;
  long long arr[n + 5];
  arr[0] = z;
  vector<pair<long long, long long> > v;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    v.push_back({x, y});
  }
  for (int i = 1; i <= n; i++) {
    arr[i] = 7 - arr[i - 1];
  }
  bool flag = 0;
  for (int i = 0; i < n; i++) {
    if ((arr[i] == v[i].first || arr[i + 1] == v[i].first) ||
        (arr[i] == v[i].second || arr[i + 1] == v[i].second)) {
      flag = true;
    }
  }
  if (flag == 1) {
    cout << "NO";
  } else {
    cout << "YES";
  }
}
