#include <bits/stdc++.h>
int main() {
  int n, x;
  scanf("%d%d", &n, &x);
  int i, j, k;
  int a[500], b[500];
  for (i = 1; i <= n; i++) {
    scanf("%d%d", &a[i], &b[i]);
  }
  int sign = 1;
  int temp;
  temp = x;
  for (i = 1; i <= n; i++) {
    if (a[i] == 7 - temp || b[i] == 7 - temp || 7 - a[i] == 7 - temp ||
        7 - b[i] == 7 - temp || a[i] == temp || b[i] == temp ||
        7 - a[i] == temp || 7 - b[i] == temp) {
      sign = 0;
      break;
    }
    temp = 7 - x;
  }
  if (sign)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
