#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, a, b, temp = 1;
  cin >> n >> x;
  int nn = n;
  while (nn--) {
    cin >> a >> b;
    if (a == x || a == 7 - x || b == x || b == 7 - x) {
      temp = 0;
      break;
    }
  }
  if (temp)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
