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