#include <bits/stdc++.h>
using namespace std;
void back_rotation(int cube[]);
void left_rotation(int cube[]);
void down_rotation(int cube[]);
int verify(int cube[]);
int check(int cube[]);
int main() {
  int i;
  int cube[30];
  for (i = 1; i <= 24; i++) cin >> cube[i];
  if (check(cube))
    cout << "YES";
  else
    cout << "NO";
}
int check(int cube[]) {
  back_rotation(cube);
  if (verify(cube)) return 1;
  back_rotation(cube);
  back_rotation(cube);
  if (verify(cube)) return 1;
  back_rotation(cube);
  left_rotation(cube);
  if (verify(cube)) return 1;
  left_rotation(cube);
  left_rotation(cube);
  if (verify(cube)) return 1;
  left_rotation(cube);
  down_rotation(cube);
  if (verify(cube)) return 1;
  down_rotation(cube);
  down_rotation(cube);
  if (verify(cube)) return 1;
  down_rotation(cube);
  return 0;
}
int verify(int cube[]) {
  if (((cube[1] == cube[2]) && (cube[2] == cube[3]) && (cube[3] == cube[4])) &&
      ((cube[5] == cube[6]) && (cube[6] == cube[7]) && (cube[7] == cube[8])) &&
      ((cube[9] == cube[10]) && (cube[10] == cube[11]) &&
       (cube[11] == cube[12])) &&
      ((cube[17] == cube[18]) && (cube[18] == cube[19]) &&
       (cube[19] == cube[20])))
    return 1;
  return 0;
}
void back_rotation(int cube[]) {
  int x;
  x = cube[9];
  cube[9] = cube[11];
  cube[11] = cube[12];
  cube[12] = cube[10];
  cube[10] = x;
  x = cube[7];
  cube[7] = cube[15];
  cube[15] = cube[23];
  cube[23] = cube[19];
  cube[19] = x;
  x = cube[8];
  cube[8] = cube[16];
  cube[16] = cube[24];
  cube[24] = cube[20];
  cube[20] = x;
}
void left_rotation(int cube[]) {
  int x;
  x = cube[13];
  cube[13] = cube[15];
  cube[15] = cube[16];
  cube[16] = cube[14];
  cube[14] = x;
  x = cube[1];
  cube[1] = cube[24];
  cube[24] = cube[9];
  cube[9] = cube[5];
  cube[5] = x;
  x = cube[3];
  cube[3] = cube[22];
  cube[22] = cube[11];
  cube[11] = cube[7];
  cube[7] = x;
}
void down_rotation(int cube[]) {
  int x;
  x = cube[7];
  cube[7] = cube[8];
  cube[8] = cube[6];
  cube[6] = cube[5];
  cube[5] = x;
  x = cube[4];
  cube[4] = cube[14];
  cube[14] = cube[9];
  cube[9] = cube[19];
  cube[19] = x;
  x = cube[3];
  cube[3] = cube[16];
  cube[16] = cube[10];
  cube[10] = cube[17];
  cube[17] = x;
}
