#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  bool flag(true);
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    if (x == k || x == 7 - k || y == k || y == 7 - k) {
      flag = false;
    }
  }
  (flag) ? cout << "YES" : cout << "NO";
}
