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