#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int x;
  cin >> x;
  vector<int> a;
  vector<int> b;
  vector<int> c;
  vector<int> d;
  int t1, t2, t3, t4;
  for (int i = 0; i < n; i++) {
    cin >> t1 >> t2;
    a.push_back(t1);
    b.push_back(t2);
    t3 = 7 - t1;
    c.push_back(t3);
    t4 = 7 - t2;
    d.push_back(t4);
  }
  int t5 = 7 - x;
  for (int i = 0; i < n; i++) {
    if (d[i] == t5 || c[i] == t5 || d[i] == x || c[i] == x) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}
