#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, s, k;
  cin >> a >> s;
  for (int i = 0; i < a * 2; i++) {
    cin >> k;
    if (k == s || k == 7 - s) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
}
