#include <bits/stdc++.h>
using namespace std;
int v[25];
bool corect() {
  if (v[1] != v[2] || v[1] != v[3] || v[1] != v[4] || v[2] != v[3] ||
      v[2] != v[4] || v[3] != v[4])
    return false;
  if (v[5] != v[6] || v[5] != v[7] || v[5] != v[8] || v[6] != v[7] ||
      v[6] != v[8] || v[7] != v[8])
    return false;
  if (v[9] != v[10] || v[9] != v[11] || v[9] != v[12] || v[10] != v[11] ||
      v[10] != v[12] || v[11] != v[12])
    return false;
  if (v[17] != v[18] || v[17] != v[19] || v[17] != v[20] || v[18] != v[19] ||
      v[18] != v[20] || v[19] != v[20])
    return false;
  if (v[21] != v[22] || v[21] != v[23] || v[21] != v[24] || v[22] != v[23] ||
      v[22] != v[24] || v[23] != v[24])
    return false;
  if (v[13] != v[14] || v[13] != v[15] || v[13] != v[16] || v[14] != v[15] ||
      v[14] != v[16] || v[15] != v[16])
    return false;
  return true;
}
void rotatie_verticala_sus() {
  int aux = v[6];
  v[6] = v[10];
  v[10] = v[23];
  v[23] = v[2];
  v[2] = aux;
  aux = v[8];
  v[8] = v[12];
  v[12] = v[21];
  v[21] = v[4];
  v[4] = aux;
  aux = v[17];
  v[17] = v[19];
  v[19] = v[20];
  v[20] = v[18];
  v[18] = aux;
}
void rotatie_verticala_jos() {
  int aux = v[2];
  v[2] = v[23];
  v[23] = v[10];
  v[10] = v[6];
  v[6] = aux;
  aux = v[4];
  v[4] = v[21];
  v[21] = v[12];
  v[12] = v[8];
  v[8] = aux;
  aux = v[17];
  v[17] = v[18];
  v[18] = v[20];
  v[20] = v[19];
  v[19] = aux;
}
void rotatie_orizontala_stanga() {
  int aux = v[7];
  v[7] = v[19];
  v[19] = v[23];
  v[23] = v[15];
  v[15] = aux;
  aux = v[8];
  v[8] = v[20];
  v[20] = v[24];
  v[24] = v[16];
  v[16] = aux;
  aux = v[10];
  v[10] = v[12];
  v[12] = v[11];
  v[11] = v[9];
  v[9] = aux;
}
void rotatie_orizontala_dreapta() {
  int aux = v[7];
  v[7] = v[15];
  v[15] = v[23];
  v[23] = v[19];
  v[19] = aux;
  aux = v[8];
  v[8] = v[16];
  v[16] = v[24];
  v[24] = v[20];
  v[20] = aux;
  aux = v[9];
  v[9] = v[11];
  v[11] = v[12];
  v[12] = v[10];
  v[10] = aux;
}
void rotatie_fata_stanga() {
  int aux = v[6];
  v[6] = v[5];
  v[5] = v[7];
  v[7] = v[8];
  v[8] = aux;
  aux = v[16];
  v[16] = v[10];
  v[10] = v[17];
  v[17] = v[3];
  v[3] = aux;
  aux = v[14];
  v[14] = v[9];
  v[9] = v[19];
  v[19] = v[4];
  v[4] = aux;
}
void rotatie_fata_dreapta() {
  int aux = v[8];
  v[8] = v[7];
  v[7] = v[5];
  v[5] = v[6];
  v[6] = aux;
  aux = v[3];
  v[3] = v[17];
  v[17] = v[10];
  v[10] = v[16];
  v[16] = aux;
  aux = v[4];
  v[4] = v[19];
  v[19] = v[9];
  v[9] = v[14];
  v[14] = aux;
}
int main() {
  for (int i = 1; i <= 24; ++i) cin >> v[i];
  rotatie_verticala_sus();
  if (corect()) {
    cout << "YES";
    return 0;
  }
  rotatie_verticala_jos();
  rotatie_verticala_jos();
  if (corect()) {
    cout << "YES";
    return 0;
  }
  rotatie_verticala_sus();
  rotatie_orizontala_dreapta();
  if (corect()) {
    cout << "YES";
    return 0;
  }
  rotatie_orizontala_stanga();
  rotatie_orizontala_stanga();
  if (corect()) {
    cout << "YES";
    return 0;
  }
  rotatie_orizontala_dreapta();
  rotatie_fata_dreapta();
  if (corect()) {
    cout << "YES";
    return 0;
  }
  rotatie_fata_stanga();
  rotatie_fata_stanga();
  if (corect()) {
    cout << "YES";
    return 0;
  }
  cout << "NO";
  return 0;
}
