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