#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int x;
  cin >> x;
  long long int prev1 = 0;
  long long int prev2 = 0;
  for (long long int i = 0; i < n; i++) {
    long long int a, b;
    cin >> a >> b;
    if (prev1 == 0 && prev2 == 0) {
      prev1 = x;
      prev2 = 7 - x;
    } else {
      if (a == prev1 || b == prev1 || a == prev2 || b == prev2) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  cout << "YES" << endl;
}
