#include <bits/stdc++.h>
using namespace std;
int work(int a, int b) {
  if ((a == 1 || a == 2 || a == 6 || a == 5) &&
      (b == 1 || b == 2 || b == 6 || b == 5))
    return 3;
  if ((a == 1 || a == 3 || a == 6 || a == 4) &&
      (b == 1 || b == 3 || b == 6 || b == 4))
    return 2;
  if ((a == 3 || a == 2 || a == 5 || a == 4) &&
      (b == 3 || b == 2 || b == 5 || b == 4))
    return 1;
}
int main() {
  int n, x, y, a, b;
  int found = false;
  scanf("%d%d", &n, &x);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &a, &b);
    y = work(a, b);
    if (y != x && y != 7 - x) {
      found = true;
    }
  }
  if (found)
    printf("NO\n");
  else
    printf("YES\n");
  return 0;
}
