#include <bits/stdc++.h>
using namespace std;
int vec[24];
int lados[3][8] = {{3, 4, 17, 19, 10, 9, 16, 14},
                   {1, 3, 5, 7, 9, 11, 24, 22},
                   {13, 14, 5, 6, 17, 18, 21, 22}};
bool prob() {
  for (int i = 0; i < 24; i += 4) {
    int n = vec[i];
    for (int k = i; k < i + 4; k++)
      if (vec[k] != n) return false;
  }
  return true;
}
void girar(int l, int der) {
  if (der > 0) {
    int prim = vec[lados[l][0]];
    for (int k = 0; k < 8; k++) vec[lados[l][k]] = vec[lados[l][(k + 1) % 8]];
    vec[lados[l][7]] = prim;
  } else {
    int prim = vec[lados[l][7]];
    for (int k = 6; k >= 0; k--) vec[lados[l][k + 1]] = vec[lados[l][k]];
    vec[lados[l][0]] = prim;
  }
}
void prin() {
  for (int i = 0; i < 24; i++) cout << vec[i] << " ";
  cout << endl;
}
bool solve() {
  for (int i = 0; i < 3; i++) {
    girar(i, 1);
    girar(i, 1);
    if (prob()) return true;
    girar(i, -1);
    girar(i, -1);
    girar(i, -1);
    girar(i, -1);
    if (prob()) return true;
    girar(i, 1);
    girar(i, 1);
  }
  return false;
}
int main() {
  for (int i = 0; i < 24; i++) cin >> vec[i];
  for (int i = 0; i < 3; i++)
    for (int k = 0; k < 8; k++) lados[i][k]--;
  if (solve()) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
