#include <bits/stdc++.h>
short n, x, i, j;
short a, b;
int main() {
  scanf("%hd %hd", &n, &x);
  for (i = 0; i < n; ++i) {
    scanf("%hd %hd", &a, &b);
    if (x == a || x == 7 - a || x == b || x == 7 - b) break;
  }
  if (i < n)
    puts("NO");
  else
    puts("YES");
  return 0;
}
