#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin.tie(0);
  cout.tie(0);
  vector<pair<int, int>> p;
  int n, x, y;
  cin >> n >> x;
  p.push_back({x, 7 - x});
  while (n--) {
    cin >> x >> y;
    if (x == p[0].first or x == p[0].second or y == p[0].first or
        y == p[0].second) {
      cout << "NO\n";
      return 0;
    } else
      continue;
  }
  cout << "YES\n";
}
