#include <bits/stdc++.h>
using namespace std;
int a[24];
int cycle[6][8] = {
    {13, 14, 5, 6, 17, 18, 21, 22}, {15, 16, 7, 8, 19, 20, 23, 24},
    {1, 3, 5, 7, 9, 11, 24, 22},    {2, 4, 6, 8, 10, 12, 23, 21},
    {3, 4, 17, 19, 10, 9, 16, 14},  {21, 23, 12, 10, 8, 6, 4, 2}};
bool check(vector<int>& x) {
  for (int i = 0; i < 24; i += 4) {
    for (int j = 1; j <= 3; j++) {
      if (x[i + j] != x[i]) return false;
    }
  }
  return true;
}
void print(vector<int>& vec) {
  for (int ele : vec) printf("%d ", ele);
  printf("\n");
}
bool solve() {
  for (int i = 0; i < 6; i++) {
    vector<int> v1(a, a + 24);
    int x = v1[cycle[i][0]], y = v1[cycle[i][1]];
    for (int j = 0; j < 3; j++) {
      v1[cycle[i][j * 2]] = v1[cycle[i][j * 2 + 2]];
      v1[cycle[i][j * 2 + 1]] = v1[cycle[i][j * 2 + 3]];
    }
    v1[cycle[i][6]] = x;
    v1[cycle[i][7]] = y;
    if (check(v1)) return true;
    vector<int> v2(a, a + 24);
    x = v2[cycle[i][6]];
    y = v2[cycle[i][7]];
    for (int j = 3; j > 0; j--) {
      v2[cycle[i][j * 2]] = v2[cycle[i][j * 2 - 2]];
      v2[cycle[i][j * 2 + 1]] = v2[cycle[i][j * 2 - 1]];
    }
    v2[cycle[i][0]] = x;
    v2[cycle[i][1]] = y;
    if (check(v2)) return true;
  }
  return false;
}
int main() {
  for (int i = 0; i < 6; i++)
    for (int j = 0; j < 8; j++) cycle[i][j]--;
  for (int i = 0; i < 24; i++) scanf("%d", a + i);
  if (solve())
    printf("YES\n");
  else
    printf("NO\n");
}
