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