#include <bits/stdc++.h>
using namespace std;
int x[25];
bool f(int a, int b, int c, int d) {
  bool p = (x[a] == x[b]) && (x[c] == x[d]) && (x[a] == x[c]);
  return p;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  for (int i = 1; i <= 24; i++) {
    cin >> x[i];
  }
  int v1[10] = {1, 3, 5, 7, 9, 11, 24, 22, 1, 3};
  int v2[10] = {2, 4, 6, 8, 10, 12, 23, 21, 2, 4};
  int v3[10] = {13, 14, 5, 6, 17, 18, 21, 22, 13, 14};
  int v4[10] = {15, 16, 7, 8, 19, 20, 23, 24, 15, 16};
  int v5[10] = {1, 2, 18, 20, 12, 11, 15, 13, 1, 2};
  int v6[10] = {3, 4, 17, 19, 10, 9, 16, 14, 3, 4};
  bool b0 = !(f(13, 14, 15, 16) && f(17, 18, 19, 20)), b1 = b0,
       b2 = !(f(1, 2, 3, 4) && f(9, 10, 11, 12)), b3 = b2;
  bool b4 = !(f(5, 6, 7, 8) && f(21, 22, 23, 24)), b5 = b4;
  for (int i = 0; i <= 6; i += 2) {
    if (!(f(v1[i], v1[i + 1], v2[i + 2], v2[i + 3]))) b0 = 1;
    if (!(f(v2[i], v2[i + 1], v1[i + 2], v1[i + 3]))) b1 = 1;
    if (!(f(v4[i], v4[i + 1], v3[i + 2], v3[i + 3]))) b2 = 1;
    if (!(f(v3[i], v3[i + 1], v4[i + 2], v4[i + 3]))) b3 = 1;
    if (!(f(v5[i], v5[i + 1], v6[i + 2], v6[i + 3]))) b4 = 1;
    if (!(f(v6[i], v6[i + 1], v5[i + 2], v5[i + 3]))) b5 = 1;
  }
  if (!b0 || !b1 || !b2 || !b3 || !b4 || !b5)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
