#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  int top;
  cin >> n;
  cin >> top;
  int prevTop = 7 - top;
  for (int i = 0; i < n; ++i) {
    int a, b, c, d;
    cin >> a >> b;
    c = 7 - a;
    d = 7 - b;
    unordered_set<int> s = {a, b, c, d};
    if (s.count(prevTop)) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}
