#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e2;
int p[maxn + 5], q[maxn + 5], x[maxn + 5], y[maxn + 5], n;
void work(int i) {
  x[i] = y[i] = 0;
  bool t[7] = {0};
  t[p[i]] = t[q[i]] = t[7 - p[i]] = t[7 - q[i]] = 1;
  for (int j = 1; j <= 6; ++j)
    if (!t[j]) {
      if (!x[i])
        x[i] = j;
      else
        y[i] = j;
    }
}
bool slove(int k) {
  int t = k, tt;
  for (int i = 1; i <= n; ++i) {
    if (x[i] == t)
      tt = y[i];
    else
      tt = x[i];
    if (i == n) break;
    if (tt == x[i + 1])
      t = y[i + 1];
    else if (tt == y[i + 1])
      t = x[i + 1];
    else
      return false;
  }
  return true;
}
int main() {
  int t;
  scanf("%d%d", &n, &t);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &p[i], &q[i]);
    work(i);
  }
  if (slove(t))
    puts("YES");
  else
    puts("NO");
  return 0;
}
