#include <bits/stdc++.h>
using namespace std;
const long long oo = 2e9, mod = 1000000007;
int main() {
  cin.sync_with_stdio(false);
  int a[101], b[101];
  int top;
  int n;
  cin >> n;
  cin >> top;
  bool r;
  r = 1;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    if (r && i) {
      if ((a[i] == top || a[i] + top == 7) || b[i] == top || b[i] + top == 7) {
        r = 0;
      }
    }
  }
  if (r)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
