#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int x;
  int a;
  int b;
  int t;
  int r;
  int y;
  int s = 0;
  scanf("%d", &n);
  scanf("%d", &x);
  while (s < n) {
    scanf("%d %d", &a, &b);
    if (a == x || b == x || b == 7 - x || a == 7 - x) {
      t = 1;
      break;
    } else {
      t = 0;
    }
    s++;
  }
  if (t == 0)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
