#include <bits/stdc++.h>
using namespace std;
vector<int> roda(int f, vector<int> valores) {
  vector<int> temp(valores);
  if (f == 0) {
    temp[17] = valores[5];
    temp[18] = valores[6];
    temp[21] = valores[17];
    temp[22] = valores[18];
    temp[13] = valores[21];
    temp[14] = valores[22];
    temp[5] = valores[13];
    temp[6] = valores[14];
  } else if (f == 1) {
    temp[3] = valores[17];
    temp[4] = valores[19];
    temp[16] = valores[3];
    temp[14] = valores[4];
    temp[10] = valores[16];
    temp[9] = valores[14];
    temp[17] = valores[10];
    temp[19] = valores[9];
  } else if (f == 2) {
    temp[20] = valores[7];
    temp[19] = valores[8];
    temp[24] = valores[20];
    temp[23] = valores[19];
    temp[15] = valores[24];
    temp[16] = valores[23];
    temp[7] = valores[15];
    temp[8] = valores[16];
  } else if (f == 3) {
    temp[1] = valores[24];
    temp[3] = valores[22];
    temp[5] = valores[1];
    temp[7] = valores[3];
    temp[9] = valores[5];
    temp[11] = valores[7];
    temp[24] = valores[9];
    temp[22] = valores[11];
  } else if (f == 4) {
    temp[2] = valores[23];
    temp[4] = valores[21];
    temp[6] = valores[6];
    temp[8] = valores[8];
    temp[10] = valores[10];
    temp[12] = valores[12];
    temp[23] = valores[23];
    temp[21] = valores[21];
  } else if (f == 5) {
    temp[1] = valores[15];
    temp[2] = valores[13];
    temp[18] = valores[1];
    temp[20] = valores[2];
    temp[12] = valores[18];
    temp[11] = valores[20];
    temp[15] = valores[12];
    temp[13] = valores[11];
  }
  return temp;
}
bool checa(vector<int> valores) {
  for (int i = 0; i < 6; i++) {
    int cor = valores[1 + i * 4];
    for (int j = 1; j < 4; j++)
      if (valores[1 + i * 4 + j] != cor) return false;
  }
  return true;
}
int main() {
  vector<int> valores(25);
  int i;
  for (i = 1; i < 25; i++) cin >> valores[i];
  int resp = 0;
  for (i = 0; i < 6; i++) {
    resp = resp || checa(roda(i, valores));
    resp = resp || checa(roda(i, roda(i, roda(i, valores))));
  }
  if (resp)
    puts("YES");
  else
    puts("NO");
}
