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