#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, x;
  cin >> n >> x;
  long long int f = 0;
  while (n--) {
    long long int a, b;
    cin >> a >> b;
    if (a == x || b == x) {
      cout << "NO" << endl;
      f = 1;
      break;
    } else if (abs(7 - a) == x || abs(7 - b) == x) {
      cout << "NO" << endl;
      f = 1;
      break;
    }
  }
  if (f == 0) cout << "YES" << endl;
}
