#include <bits/stdc++.h>
using namespace std;
int a[105], b[105];
int bottom[] = {0, 6, 5, 4, 3, 2, 1};
int check[10][5];
int main() {
  int n, x;
  scanf(" %d ", &n);
  scanf(" %d ", &x);
  for (int i = 0; i < n; i++) scanf(" %d %d ", &a[i], &b[i]);
  int bot = bottom[x];
  bool ans = true;
  for (int i = 0; i < n; i++)
    if (a[i] == bot || a[i] == x || b[i] == bot || b[i] == x) ans = false;
  if (ans)
    puts("YES");
  else
    puts("NO");
  return 0;
}
