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