#include <bits/stdc++.h>
int main() {
  int a, b, c, n, x, i, vet[7];
  char boolean = 0;
  scanf("%d", &n);
  n--;
  scanf("%d %d %d", &a, &b, &c);
  x = 7 - a;
  while (n--) {
    scanf("%d %d", &a, &b);
    for (i = 1; i <= 6; i++) vet[i] = 0;
    vet[a] = 1;
    vet[7 - a] = 1;
    vet[b] = 1;
    vet[7 - b] = 1;
    if (vet[x] == 1) boolean = 1;
  }
  printf("%s\n", boolean ? "NO" : "YES");
  return 0;
}
