#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n, a[110], b[110], x;
  cin >> n;
  cin >> x;
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i];
    if (a[i] == x || b[i] == x || a[i] == 7 - x || b[i] == 7 - x) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}
