#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, s;
  while (cin >> n >> s) {
    int a, b;
    cin >> a >> b;
    int i = 1, bo = 1;
    for (i = 1; i < n; i++) {
      cin >> a >> b;
      if (a == s || a == 7 - s || b == s || b == 7 - s) bo = 0;
    }
    if (bo)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
