#include <bits/stdc++.h>
using namespace std;
const int MAX = 105;
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int x;
  cin >> x;
  for (int i = 0; i < n; i++) {
    x = 7 - x;
    int a, b;
    cin >> a >> b;
    if (a == x || b == x || 7 - a == x || 7 - b == x) {
      cout << "NO\n";
      return 0;
    }
    for (int j = 1; j <= 6; j++)
      if (a != j && b != j && 7 - a != j && 7 - b != j) x = j;
  }
  cout << "YES\n";
  return 0;
}
