#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T x, T y) {
  if (x < y) swap(x, y);
  while (y > 0) {
    T f = x % y;
    x = y;
    y = f;
  }
  return x;
}
template <typename T>
pair<T, T> exgcd(T x, T y) {
  int sw = 0;
  if (x < y) sw = true, swap(x, y);
  pair<T, T> r = make_pair(1, 0);
  while (y > 0) {
    T f = x % y;
    r = make_pair(r.second, r.first - (x / y) * r.second);
    x = y;
    y = f;
  };
  if (sw) swap(r.first, r.second);
  return r;
}
int rot[][12] = {
    {
        1,
        2,
        4,
        3,
        13,
        14,
        5,
        6,
        17,
        18,
        21,
        22,
    },
    {
        9,
        10,
        11,
        12,
        15,
        16,
        7,
        8,
        19,
        20,
        23,
        24,
    },
    {13, 14, 16, 15, 1, 3, 5, 7, 9, 11, 24, 22},
    {17, 18, 20, 19, 2, 4, 6, 8, 10, 12, 23, 21},
    {5, 6, 8, 7, 3, 4, 17, 19, 10, 9, 16, 14},
    {21, 22, 24, 23, 18, 20, 12, 11, 15, 13, 1, 2},
};
bool solved(int s[25]) {
  for (int i = 1; i < 24; i += 4) {
    if (s[i] != s[i + 1] || s[i] != s[i + 2] || s[i] != s[i + 3]) return false;
  }
  return true;
}
int main(int argc, char *argv[]) {
  std::cin.sync_with_stdio(false);
  std::cin.tie(nullptr);
  int s[25];
  cin >> s[1];
  {
    for (int i = 2; i <= 24; i++) cin >> s[i];
    int t[25];
    bool ok = false;
    for (int i = 0; i < 6; i++) {
      memcpy(t, s, sizeof(t));
      for (int j = 0; j < 4; j++) t[rot[i][(j + 1) % 4]] = s[rot[i][j]];
      for (int j = 0; j < 8; j++)
        t[rot[i][4 + ((j + 2) % 8)]] = s[rot[i][4 + j]];
      if (solved(t)) {
        ok = true;
        break;
      }
      memcpy(t, s, sizeof(t));
      for (int j = 0; j < 4; j++) t[rot[i][(j + 3) % 4]] = s[rot[i][j]];
      for (int j = 0; j < 8; j++)
        t[rot[i][4 + ((j + 6) % 8)]] = s[rot[i][4 + j]];
      if (solved(t)) {
        ok = true;
        break;
      }
    }
    cout << (ok ? "YES" : "NO") << endl;
  }
  return 0;
}
