#include <bits/stdc++.h>
using namespace std;
pair<int, int> s[150];
int main() {
  int n, x;
  int a, b;
  cin >> n >> x;
  int z = 7 - x;
  bool f = true;
  for (int i = 1; i <= n; i++) {
    cin >> a >> b;
    s[i] = make_pair(a, b);
  }
  for (int i = 1; i <= n; i++) {
    if (s[i].first + x == 7 || s[i].first + z == 7 || s[i].second + x == 7 ||
        s[i].second + z == 7) {
      f = false;
      break;
    }
  }
  if (f == true)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
