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