#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:666000000")
using namespace std;
const int inf = (1 << 30) - 1;
const long double eps = 1e-9;
const long double pi = fabs(atan2(0.0, -1.0));
void ML() {
  int *ass;
  for (;;) {
    ass = new int[2500000];
    for (int i = 0; i < 2500000; i++) ass[i] = rand();
  }
}
int n, u;
vector<pair<int, int> > a;
void LoAd() {
  cin >> n >> u;
  a.resize(n);
  for (int i = 0; i < n; i++) scanf("%d%d", &a[i].first, &a[i].second);
}
pair<int, int> ngh(const int a, const int b) {
  set<int> w;
  for (int i = 1; i <= 6; i++)
    if (i != a && i != b && i != 7 - a && i != 7 - b) w.insert(i);
  return make_pair(*w.begin(), *w.rbegin());
}
void SoLvE() {
  if (1 == n) {
    puts("YES");
    return;
  }
  for (int i = 0; i < n; i++) {
    u = 7 - u;
    pair<int, int> nxt = ngh(a[i].first, a[i].second);
    if (u != nxt.first && u != nxt.second) {
      puts("NO");
      return;
    }
  }
  puts("YES");
}
int main() {
  srand((int)time(NULL));
  LoAd();
  SoLvE();
  return 0;
}
