#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int k;
  cin >> k;
  int x = 7 - k;
  vector<pair<int, int>> v;
  for (int i = 0; i < n; i++) {
    int y, z;
    cin >> y >> z;
    v.push_back(make_pair(y, z));
  }
  int a[n + 1];
  for (int i = 1; i < n; i++) {
    memset(a, -1, sizeof(a));
    a[v[i].first] = 0;
    a[7 - v[i].first] = 0;
    a[v[i].second] = 0;
    a[7 - v[i].second] = 0;
    if (a[x] == 0) {
      cout << "NO";
      return 0;
    } else {
      x = 7 - x;
    }
  }
  cout << "YES";
  return 0;
}
