#include <bits/stdc++.h>
using namespace std;
int n, x, i, a[200], s1, s2, j = 2;
string can = "YES";
int main() {
  cin >> n;
  cin >> x;
  x = 7 - x;
  for (i = 0; i < n * 2; i++) {
    cin >> a[i];
  }
  for (i = 1; i < n; i++) {
    s1 = a[j];
    s2 = a[j + 1];
    if (x == s1 || x == s2 || x == 7 - s2 || x == 7 - s1) {
      can = "NO";
      break;
    }
    j += 2;
  }
  cout << can;
}
