#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, top;
  cin >> n >> top;
  long long x, y;
  for (long long i = 0; i < n; ++i) {
    cin >> x >> y;
    if (x == top || x == 7 - top || y == top || y == 7 - top) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}
