#include <bits/stdc++.h>
using namespace std;
bool check(vector<int> x) {
  for (int i = 1; i < 24; i += 4) {
    int c = x[i];
    for (int j = 0; j < 4; j++) {
      if (x[i + j] != c) return 0;
    }
  }
  puts("YES");
  return 1;
}
int main() {
  vector<int> C(25);
  for (int i = 1; i <= 24; i++) cin >> C[i];
  vector<int> P(26), t(26);
  for (int i = 1; i <= 24; i++) P[i] = i;
  P[2] = 6;
  P[4] = 8;
  P[6] = 10;
  P[8] = 12;
  P[17] = 19;
  P[18] = 17;
  P[20] = 18;
  P[19] = 20;
  P[10] = 23;
  P[12] = 21;
  P[21] = 4;
  P[23] = 2;
  for (int i = 1; i <= 24; i++) t[i] = C[P[i]];
  if (check(t)) return 0;
  for (int i = 1; i <= 24; i++) t[P[i]] = C[i];
  if (check(t)) return 0;
  for (int i = 1; i <= 24; i++) P[i] = i;
  P[7] = 15;
  P[8] = 16;
  P[19] = 7;
  P[20] = 8;
  P[23] = 19;
  P[24] = 20;
  P[15] = 23;
  P[16] = 24;
  P[9] = 11;
  P[10] = 9;
  P[11] = 12;
  P[12] = 10;
  for (int i = 1; i <= 24; i++) t[i] = C[P[i]];
  if (check(t)) return 0;
  for (int i = 1; i <= 24; i++) t[P[i]] = C[i];
  if (check(t)) return 0;
  for (int i = 1; i <= 24; i++) P[i] = i;
  P[18] = 1;
  P[20] = 2;
  P[12] = 18;
  P[11] = 20;
  P[13] = 11;
  P[15] = 12;
  P[2] = 13;
  P[1] = 15;
  P[21] = 22;
  P[22] = 24;
  P[23] = 21;
  P[24] = 23;
  for (int i = 1; i <= 24; i++) t[i] = C[P[i]];
  if (check(t)) return 0;
  for (int i = 1; i <= 24; i++) t[P[i]] = C[i];
  if (check(t)) return 0;
  puts("NO");
}
