#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, x;
  int t1, t2, flag = 1;
  cin >> n >> x;
  for (i = 0; i < n; i++) {
    cin >> t1 >> t2;
    if (x == t1 || x == 7 - t1) flag = 0;
    if (x == t2 || x == 7 - t2) flag = 0;
  }
  if (flag == 1)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
