#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  long long x, a, b, i, f = 1, pa, push_back;
  vector<pair<long long, long long> > v(n);
  vector<long long> ch;
  cin >> x;
  cin >> a >> b;
  pa = a, push_back = b;
  if (a + b == 7) f = 0;
  for (i = 1; i < n; i++) {
    cin >> a >> b;
    if (f == 1) {
      if (a + b != 7) {
        if (a == pa || a == 7 - pa || a == push_back || a == 7 - push_back) {
          if (b == pa || b == 7 - pa || b == push_back || b == 7 - push_back) {
            f = 1;
          } else
            f = 0;
        } else
          f = 0;
      } else
        f = 0;
    }
    pa = a, push_back = b;
  }
  if (f == 1) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}
