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