#include <bits/stdc++.h>
int main() {
  int n, d, a[101], b[101], fl = 0;
  scanf("%d%d", &n, &d);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &a[i], &b[i]);
    d = 7 - d;
    if (a[i] == d || (7 - a[i]) == d || b[i] == d || (7 - b[i]) == d)
      fl = 1;
    else
      d = 7 - d;
  }
  if (!fl)
    printf("YES");
  else
    printf("NO");
  return 0;
}
