#include <bits/stdc++.h>
using namespace std;
pair<int, int> arr[1001];
int ok[8];
int main() {
  ios_base::sync_with_stdio(0);
  int n, top, botton;
  cin >> n >> top;
  for (int i = 0; i < n; i++) cin >> arr[i].first >> arr[i].second;
  botton = 7 - top;
  for (int i = 0; i < n; i++) {
    ok[arr[i].first] = arr[i].first;
    ok[7 - arr[i].first] = 7 - arr[i].first;
    ok[arr[i].second] = arr[i].second;
    ok[7 - arr[i].second] = 7 - arr[i].second;
    if (ok[botton] == 0) {
      botton = 7 - botton;
    } else {
      cout << "NO";
      return 0;
    }
    fill(ok, ok + 8, 0);
  }
  cout << "YES";
  return 0;
}
