#include <bits/stdc++.h>
using namespace std;
double const PI = acos(-1.0);
double const EPS = 1e-9;
int main() {
  int n;
  scanf("%d", &n);
  int x;
  scanf("%d", &x);
  int a;
  int b;
  bool pos = true;
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a, &b);
    pos = pos && a != x && b != x && 7 - a != x && 7 - b != x;
  }
  printf("%s\n", pos ? "YES" : "NO");
  return 0;
}
