#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int t;
  cin >> t;
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    int d[7] = {0};
    d[a] = 1;
    d[7 - a] = 1, d[b] = 1, d[7 - b] = 1;
    d[t] = 1;
    int cn = 0;
    for (int j = 1; j < 7; ++j) {
      if (d[j] == 0) {
        t = 7 - j;
        cn++;
      }
    }
    if (cn == 2) return (cout << "NO", 0);
  }
  cout << "YES";
  return 0;
}
