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