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