#include <bits/stdc++.h>
using namespace std;
int main() {
  int T, h, a, b, i;
  bool yes = true;
  cin >> T;
  cin >> h;
  while (T--) {
    cin >> a >> b;
    if (a == h || b == h || a == 7 - h || b == 7 - h) yes = false;
  }
  if (yes)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}
