#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, t, i;
  int a[111][2];
  scanf("%d", &n);
  scanf("%d", &t);
  for (i = 0; i < n; i++) scanf("%d %d", &a[i][0], &a[i][1]);
  t = 7 - t;
  for (i = 1; i <= n - 1; i++) {
    if (t == a[i][0] or t == a[i][1] or t == 7 - a[i][0] or t == 7 - a[i][1])
      break;
  }
  if (i == n)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
