#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int top_num;
  cin >> top_num;
  int correct_assumptions = 0;
  for (int i = 0; i < 2 * n; i++) {
    int x;
    cin >> x;
    if (x != top_num && x != 7 - top_num) correct_assumptions++;
  }
  if (correct_assumptions == 2 * n)
    cout << "YES";
  else {
    cout << "NO";
  }
}
