#include <bits/stdc++.h>
using namespace std;
int main() {
  int cnt = 0;
  int n, m;
  cin >> n >> m;
  int arr1[n];
  int arr2[n];
  for (int i = 0; i < n; i++) {
    cin >> arr1[i] >> arr2[i];
  }
  int v = 7 - m;
  for (int i = 0; i < n; i++) {
    if (v == arr1[i] || m == arr1[i] || v == arr2[i] || m == arr2[i]) {
      cnt++;
    }
  }
  if (cnt > 0) {
    cout << "NO";
  } else {
    cout << "YES";
  }
}
