#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC optimize("Os")
using namespace std;
int main(int argc, char const *argv[]) {
  long long i, t, n, a = 0, j, x = 1, b = 0, c = 0, k = 0, m = -1;
  string str, s, ls = "", rs = "";
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  m = 7 - k;
  while (n--) {
    cin >> a >> b;
    if (a == m || 7 - a == m || b == m || 7 - b == m) x = 0;
  }
  if (x)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
