#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d;
  cin >> a >> b;
  bool r = true;
  while (a--) {
    cin >> c >> d;
    if (b == c || b == d || b == 7 - c || b == 7 - d) {
      r = false;
    } else
      b = 7 - b;
  }
  if (r == true)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
