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