#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, t;
  scanf("%d%d", &n, &t);
  int x, y;
  vector<pair<int, int> > v(n);
  for (int i = 0; i < (int)(n); ++i) {
    scanf("%d%d", &x, &y);
    v[i].first = x;
    v[i].second = y;
  }
  int a[4] = {v[0].first, v[0].second, 7 - v[0].first, 7 - v[0].second};
  bool f = true;
  for (int i = 0; i < (int)(n); ++i) {
    if (find(a, a + 4, v[i].first) == a + 4 or
        find(a, a + 4, v[i].second) == a + 4)
      f = false;
  }
  cout << (f ? "YES" : "NO");
}
