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