#include <bits/stdc++.h>
using namespace std;
template <class T>
void _R(T &x) {
  cin >> x;
}
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template <class T, class... U>
void R(T &head, U &...tail) {
  _R(head);
  R(tail...);
}
template <class T>
void _W(const T &x) {
  cout << x;
}
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template <class T, class U>
void _W(const pair<T, U> &x) {
  _W(x.first);
  putchar(' ');
  _W(x.second);
}
template <class T>
void _W(const vector<T> &x) {
  for (auto i = x.begin(); i != x.end(); _W(*i++))
    if (i != x.cbegin()) putchar(' ');
}
void W() {}
template <class T, class... U>
void W(const T &head, const U &...tail) {
  _W(head);
  putchar(sizeof...(tail) ? ' ' : '\n');
  W(tail...);
}
int MOD = 1e9 + 7;
void ADD(long long &x, long long v) {
  x = (x + v) % MOD;
  if (x < 0) x += MOD;
}
const int SIZE = 1e6 + 10;
int a[24];
int d[6][8] = {
    {3, 4, 17, 19, 9, 10, 14, 16},  {1, 2, 22, 24, 11, 12, 13, 15},
    {5, 6, 17, 18, 21, 22, 13, 14}, {7, 8, 19, 20, 23, 24, 15, 16},
    {6, 8, 10, 12, 21, 23, 2, 4},   {5, 7, 9, 11, 22, 24, 1, 3},
};
bool valid() {
  for (int i = 0; i < (24); ++i) {
    if (a[i] != a[i - i % 4]) return 0;
  }
  return 1;
}
void AC() {
  W("YES");
  exit(0);
}
void my_rotate(int id) {
  int tmp[2];
  tmp[0] = a[d[id][0]];
  tmp[1] = a[d[id][1]];
  for (int i = 0; i < (6); ++i) a[d[id][i]] = a[d[id][i + 2]];
  a[d[id][6]] = tmp[0];
  a[d[id][7]] = tmp[1];
}
int main() {
  for (int i = 0; i < (24); ++i) R(a[i]);
  for (int i = 0; i < (6); ++i)
    for (int j = 0; j < (8); ++j) d[i][j]--;
  for (int i = 0; i < (6); ++i) {
    my_rotate(i);
    if (valid()) AC();
    for (int j = 0; j < (2); ++j) my_rotate(i);
    if (valid()) AC();
    my_rotate(i);
  }
  W("NO");
  return 0;
}
