#include <bits/stdc++.h>
using namespace std;
int x, y, a, b, n;
void solve() {
  bool flag = true;
  scanf("%d", &x);
  for (int i = 0; i < n; i++) {
    y = 7 - x;
    scanf("%d %d", &a, &b);
    if (x == a || x == b || y == a || y == b) {
      flag = false;
    }
  }
  puts(flag ? "YES" : "NO");
  return;
}
int main() {
  while (~scanf("%d", &n)) {
    solve();
  }
  return 0;
}
