#include <bits/stdc++.h>
using namespace std;
map<int, int> m;
int n;
void solve() {
  int i, x, y, dinh;
  bool si = false;
  m.clear();
  scanf("%d", &dinh);
  m[dinh] = 1;
  m[7 - dinh] = 1;
  for (i = 1; i <= n; i++) {
    scanf("%d%d", &x, &y);
    if ((x == y || m[x] == 1 || m[y] == 1 || m[7 - x] == 1 || m[7 - y] == 1) &&
        si == false) {
      cout << "NO\n";
      si = true;
    }
  }
  if (si == false) cout << "YES\n";
}
int main() {
  while (scanf("%d", &n) > 0) solve();
  return 0;
}
