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