#include <bits/stdc++.h>
int n, ust, x, y, mark[10];
int main() {
  scanf("%d", &n);
  scanf("%d", &ust);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &x, &y);
    mark[x] = 1;
    mark[y] = 1;
    mark[7 - x] = 1;
    mark[7 - y] = 1;
    if (!mark[7 - ust])
      for (int j = 0; j < 7; j++) mark[j] = 0;
    else {
      printf("NO\n");
      return 0;
    }
  }
  printf("YES\n");
}
