#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int a[N], b[N];
int n, x;
int bt[N];
bool used[15];
bool ans = true;
int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin >> n >> x;
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i];
  }
  bt[0] = 7 - x;
  for (int i = 1; i < n; ++i) {
    memset(used, false, sizeof used);
    used[a[i]] = true;
    used[7 - a[i]] = true;
    used[b[i]] = true;
    used[7 - b[i]] = true;
    if (used[bt[i - 1]]) {
      ans = false;
      break;
    } else {
      bt[i] = 7 - bt[i - 1];
    }
  }
  if (ans) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
  return 0;
}
