#include <bits/stdc++.h>
using namespace std;
short n, i, bottom, x, y;
int main() {
  cin >> n >> bottom;
  bottom = 7 - bottom;
  for (i = 0; i < n; i++) {
    cin >> x >> y;
    if (x == 1 || y == 1 || x == 6 || y == 6) {
      if (x == 2 || y == 2 || x == 5 || y == 5) {
        if (bottom != 3 && bottom != 4) {
          cout << "NO";
          return 0;
        }
      } else {
        if (bottom != 2 && bottom != 5) {
          cout << "NO";
          return 0;
        }
      }
    } else {
      if (bottom != 1 && bottom != 6) {
        cout << "NO";
        return 0;
      }
    }
  }
  cout << "YES";
  return 0;
}
