#include <bits/stdc++.h>
using namespace std;
int const nMax = 2002;
int const inf = (1 << 30);
int n;
int c;
int a, b;
int d[7];
int main() {
  cin >> n >> c;
  for (int i = (1); i <= (n); i++) {
    memset(d, 0, sizeof(d));
    cin >> a >> b;
    d[a] = 1, d[7 - a] = 1;
    d[b] = 1;
    d[7 - b] = 1;
    d[7 - c] = 1;
    int ans = 0;
    for (int i = 1; i <= 6; i++) ans += d[i];
    if (ans < 5) {
      printf("NO\n");
      return 0;
    }
    for (int i = 1; i <= 6; i++)
      if (d[i] == 0) {
        c = i;
        break;
      }
  }
  puts("YES");
  return 0;
}
