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