#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  int n;
  cin >> n;
  int m;
  m = 7 - n;
  int flag = 0;
  while (t--) {
    int a, b;
    cin >> a >> b;
    if (a == n || a == m || b == m || b == n) {
      flag = 1;
      break;
    }
  }
  if (flag == 1)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
}
