#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int a[10][10] = {
    {1, 2, 18, 20, 12, 11, 15, 13}, {3, 4, 17, 19, 10, 9, 16, 14},
    {3, 1, 22, 24, 11, 9, 7, 5},    {4, 2, 21, 23, 12, 10, 8, 6},
    {13, 14, 5, 6, 17, 18, 21, 22}, {15, 16, 7, 8, 19, 20, 23, 24}};
int b[26], c[26];
bool check() {
  return (c[1] == c[2] and c[2] == c[3] and c[3] == c[4]) and
         (c[5] == c[6] and c[6] == c[7] and c[7] == c[8]) and
         (c[13] == c[14] and c[14] == c[15] and c[15] == c[16]) and
         (c[9] == c[10] and c[10] == c[11] and c[11] == c[12]) and
         (c[17] == c[18] and c[18] == c[19] and c[19] == c[20]) and
         (c[21] == c[22] and c[22] == c[23] and c[23] == c[24]);
}
int main() {
  for (int i = 1; i <= 24; i++) cin >> b[i];
  for (int i = 0; i <= 1; i++)
    for (int j = 0; j < 6; j++) {
      if (i) {
        for (int p = 1; p <= 24; p++) c[p] = b[p];
        for (int p = 0; p < 8; p++) {
          int t = (p + 2) % 8;
          c[a[j][p]] = b[a[j][t]];
        }
        if (check()) return cout << "YES" << endl, 0;
      } else {
        for (int p = 1; p <= 24; p++) c[p] = b[p];
        for (int p = 0; p < 8; p++) {
          int t = (p + 6) % 8;
          c[a[j][p]] = b[a[j][t]];
        }
        if (check()) return cout << "YES" << endl, 0;
      }
    }
  cout << "NO" << endl;
  return 0;
}
