#include <bits/stdc++.h>
using namespace std;
int main() {
  bool vis[7];
  int n, top, l, r;
  while (scanf("%d", &n) == 1) {
    scanf("%d", &top);
    memset(vis, false, sizeof(vis));
    for (int i = 0; i < n; i++) {
      scanf("%d %d", &l, &r);
      vis[l] = true;
      vis[7 - l] = true;
      vis[r] = true;
      vis[7 - r] = true;
    }
    if (vis[top] == false) {
      puts("YES");
    } else {
      puts("NO");
    }
  }
  return 0;
}
