#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int m = 0;
  cin >> n;
  int top;
  cin >> top;
  int num[n][2];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> num[i][j];
    }
  }
  for (int i = 0; i < n - 1; i++) {
    int x = num[i][0];
    int y = num[i][1];
    if (num[i + 1][0] == x || num[i + 1][0] == 7 - x) {
      if (num[i + 1][1] == y || num[i + 1][1] == 7 - y) {
        m = 1;
      } else {
        m = 0;
        break;
      }
    } else if (num[i + 1][0] == y || num[i + 1][0] == 7 - y) {
      if (num[i + 1][1] == x || num[i + 1][1] == 7 - x) {
        m = 1;
      } else {
        m = 0;
        break;
      }
    } else {
      m = 0;
      break;
    }
  }
  if (n == 1) {
    m = 1;
  }
  if (m) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}
