#include <bits/stdc++.h>
using namespace std;
int orient1(int x, int y) {
  int p[7];
  for (int i = 0; i < 7; i++) {
    p[i] = 0;
  }
  p[x] = 1;
  p[7 - x] = 1;
  p[y] = 1;
  p[7 - y] = 1;
  for (int i = 1; i <= 6; i++) {
    if (p[i] == 0) return i;
  }
}
int orient2(int x, int y) {
  int p[7];
  for (int i = 0; i < 7; i++) {
    p[i] = 0;
  }
  p[x] = 1;
  p[7 - x] = 1;
  p[y] = 1;
  p[7 - y] = 1;
  for (int i = 6; i >= 1; i--) {
    if (p[i] == 0) return i;
  }
}
int main() {
  int n;
  int top;
  cin >> n >> top;
  int left[n], right[n];
  int tower[n + 1][2];
  for (int i = 0; i < n; i++) {
    cin >> left[i] >> right[i];
  }
  tower[1][0] = 7 - top;
  for (int i = 0; i < n; i++) {
    if (orient1(left[i], right[i]) == top || orient2(left[i], right[i]) == top)
      continue;
    else {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;
}
