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