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