#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:500000000")
using namespace std;
bool used[7];
int a[105][7], n, i, j;
int main() {
  scanf("%d %d", &n, &a[1][1]);
  for (i = 1; i <= n; i++) {
    scanf("%d %d", &a[i][2], &a[i][3]);
    a[i][4] = 7 - a[i][2];
    a[i][5] = 7 - a[i][3];
  }
  a[1][6] = 7 - a[1][1];
  for (i = 2; i <= n; i++) {
    memset(used, 0, sizeof(used));
    for (j = 1; j <= 6; j++) used[a[i][j]] = 1;
    for (j = 1; j <= 6; j++)
      if (!used[j] && j == a[i - 1][6]) break;
    if (j <= 6) {
      a[i][6] = j;
      a[i][1] = 7 - j;
    } else {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  return 0;
}
