#include <bits/stdc++.h>
using namespace std;
const int P = 720;
int main() {
  int n, t, a, b;
  cin >> n >> t >> a >> b;
  int bo = 7 - t;
  for (int i = 2; i <= n; ++i) {
    cin >> a >> b;
    int p = P / (a * b * (7 - a) * (7 - b));
    if (p == 6) {
      if (bo != 1 && bo != 6) {
        cout << "NO";
        return 0;
      }
    } else if (p == 10) {
      if (bo != 2 && bo != 5) {
        cout << "NO";
        return 0;
      }
    } else {
      if (bo != 3 && bo != 4) {
        cout << "NO";
        return 0;
      }
    }
  }
  cout << "YES";
}
