#include <bits/stdc++.h>
long long fx[] = {1, -1, 0, 0};
long long fy[] = {0, 0, 1, -1};
using namespace std;
int main() {
  long long n, j, i, k, l, ans, a, b;
  bool flag = true;
  multimap<int, int> mp;
  multimap<int, int>::iterator it;
  cin >> n;
  cin >> k;
  for (i = 0; i < n; i++) {
    cin >> a >> b;
    if (k == a || k == b || k + a == 7 || k + b == 7 || a + b == 7) {
      flag = false;
    }
  }
  if (flag == false)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
}
