#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, top, a, b;
  cin >> n >> top >> a >> b;
  bool deductible = true;
  for (int i = 1; i < n; i++) {
    cin >> a >> b;
    if (top == a || top == b || top + a == 7 || top + b == 7) {
      deductible = false;
      break;
    }
  }
  if (deductible)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
