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