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