#include <bits/stdc++.h>
using namespace std;
const int siz = 1111;
int n;
pair<int, int> tower[siz];
bool check(int top, int index) {
  if (index > n) {
    return true;
  }
  bool dice[7];
  memset(dice, 1, sizeof(dice));
  dice[top] = 0;
  dice[tower[index].first] = 0;
  dice[7 - tower[index].first] = 0;
  dice[7 - tower[index].second] = 0;
  dice[tower[index].second] = 0;
  int j = 1;
  int count = 0;
  for (int i = 1; i <= 6; i++) {
    if (dice[i]) {
      count++;
      j = i;
    }
  }
  if (count == 1) {
    if (check(7 - j, index + 1)) {
      return true;
    }
  }
  return false;
}
int main() {
  int top;
  cin >> n >> top;
  for (int i = 1; i <= n; i++) {
    cin >> tower[i].first;
    cin >> tower[i].second;
  }
  if (check(7 - top, 2)) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
  cin >> n;
}
