#include <bits/stdc++.h>
using namespace std;
pair<int, int> p[10];
int n, x, y, z;
bool okk = true;
int main() {
  cin >> n;
  cin >> x;
  cin >> y >> z;
  p[0] = make_pair(y, z);
  p[1] = make_pair(7 - y, 7 - z);
  p[2] = make_pair(y, 7 - z);
  p[3] = make_pair(7 - y, z);
  for (int i = 0; i < n - 1; i++) {
    cin >> x >> y;
    bool ok = false;
    for (int k = 0; k < 4; k++) {
      if ((x == p[k].first && y == p[k].second) ||
          (x == p[k].second && y == p[k].first))
        ok = true;
    }
    if (ok == false) okk = false;
  }
  if (okk)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
