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