#include <bits/stdc++.h>
using namespace std;
int main() {
  int n{};
  int p{};
  int k, l, last, j;
  cin >> n >> p;
  last = 7 - p;
  for (int i = 0; i < n; ++i) {
    set<int> s{1, 2, 3, 4, 5, 6};
    cin >> k >> l;
    s.erase(k);
    s.erase(7 - k);
    s.erase(l);
    s.erase(7 - l);
    auto it = s.begin();
    j = *it;
    if (j != last && j != 7 - last) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
}
