#include <bits/stdc++.h>
int main() {
  int n, x;
  scanf("%d\n%d\n", &n, &x);
  int temp1, temp2;
  for (int i = 0; i < n; ++i) {
    scanf("%d %d\n", &temp1, &temp2);
    if (temp1 == x || temp1 == 7 - x || temp2 == x || temp2 == 7 - x) {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  return 0;
}
