#include <bits/stdc++.h>
using namespace std;
int v[6][8] = {{1, 3, 5, 7, 9, 11, 22, 24},    {2, 4, 6, 8, 10, 12, 21, 23},
               {13, 14, 5, 6, 17, 18, 21, 22}, {15, 16, 7, 8, 19, 20, 23, 24},
               {1, 2, 18, 20, 12, 11, 15, 13}, {3, 4, 17, 19, 9, 10, 14, 16}};
int g[25], temp[25];
bool check() {
  for (int i = 0; i < 6; i++) {
    set<int> st;
    for (int r = 4 * i + 1; r <= 4 * (i + 1); r++) st.insert(temp[r]);
    if (st.size() != 1) return 0;
  }
  return 1;
}
int main() {
  for (int i = 1; i < 25; i++) {
    scanf("%d", &g[i]);
  }
  for (int i = 0; i < 6; i++) {
    for (int d = 2; d <= 6; d += 4) {
      for (int k = 1; k < 25; k++) temp[k] = g[k];
      for (int k = 0; k < 8; k++) {
        temp[v[i][k]] = g[v[i][(k + d) % 8]];
      }
      if (check()) return puts("YES"), 0;
    }
  }
  puts("NO");
  return 0;
}
