#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> gr1(n), gr2(n);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> gr1[i] >> gr2[i];
  }
  for (int i = 0; i < n; i++) {
    if (gr1[i] == x || gr2[i] == x || gr1[i] == 7 - x || gr2[i] == 7 - x) {
      ans = 1;
      break;
    }
  }
  if (ans)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  return 0;
}
