#include <bits/stdc++.h>
int main() {
  int n, top;
  scanf("%d", &n);
  scanf("%d", &top);
  int below = 7 - top;
  int ctr = 0;
  while (1) {
    int f1, f2, f3, f4;
    ctr++;
    scanf("%d", &f1);
    scanf("%d", &f2);
    f3 = 7 - f1;
    f4 = 7 - f2;
    if (below == f1 || below == f2 || below == f3 || below == f4) {
      printf("NO");
      break;
    } else if (ctr == n) {
      printf("YES");
      break;
    }
  }
  return 0;
}
