#include <bits/stdc++.h>
using namespace std;
long long N, M;
struct MATRIX {
  int dim;
  long long MAT[100][100];
  MATRIX(int N, int x = -1) {
    dim = N;
    for (int i = 0; i < dim; i++)
      for (int j = 0; j < dim; j++) {
        if (x != -1 && i == j)
          MAT[i][j] = x;
        else
          MAT[i][j] = 0;
      }
  }
  void operator+=(const MATRIX& a) {
    for (int i = 0; i < a.dim; i++) {
      for (int j = 0; j < a.dim; j++) {
        MAT[i][j] += a.MAT[i][j];
      }
    }
  }
  void show() {
    for (int i = 0; i < dim; i++) {
      for (int j = 0; j < dim; j++) cout << MAT[i][j] << " ";
      cout << endl;
    }
    cout << endl;
  }
};
MATRIX operator*(MATRIX a, MATRIX b) {
  MATRIX res(a.dim);
  for (int i = 0; i < a.dim; i++) {
    for (int j = 0; j < b.dim; j++) {
      long long sum = 0;
      for (int z = 0; z < a.dim; z++) {
        sum += a.MAT[i][z] * b.MAT[z][j];
      }
      sum %= M;
      res.MAT[i][j] = sum;
    }
  }
  return res;
}
MATRIX binpow(MATRIX a, long long n) {
  MATRIX res = a;
  while (n) {
    if (n & 1) res = res * a;
    a = a * a;
    n >>= 1;
  }
  return res;
}
int main() {
  int X;
  cin >> N >> X;
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    if (a == 7 - X || b == 7 - X || a == X || b == X) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;
}
