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