func_code_string: #include <bits/stdc++.h>   using namespace std;   template <class T>   using vec = vector<T>;   template <typename Iter>   ostream &_IterOutput_(ostream &o, Iter b, Iter e, const string ss =   ,                         const string se =   ) {     o << ss;     for (auto it = b; it != e; it++) o << (it == b ?    :  ,  ) << *it;     return o << se;   }   template <typename T1, typename T2>   ostream &operator<<(ostream &o, const pair<T1, T2> &pair) {     return o <<  (  << pair.first <<  ,   << pair.second <<  ) ;   }   template <typename T>   ostream &operator<<(ostream &o, const vector<T> &vec) {     return _IterOutput_(o, begin(vec), end(vec),  [ ,  ] );   }   template <typename T>   ostream &operator<<(ostream &o, const set<T> &st) {     return _IterOutput_(o, begin(st), end(st),  { ,  } );   }   template <typename T, size_t N>   ostream &operator<<(ostream &o, const array<T, N> &arr) {     return _IterOutput_(o, begin(arr), end(arr),  | ,  | );   }   template <typename T1, typename T2>   ostream &operator<<(ostream &o, const map<T1, T2> &mp) {     o <<  { ;     for (auto it = mp.begin(); it != mp.end(); it++) {       o << (it == mp.begin() ?    :  ,  ) << it->first <<  :  << it->second;     }     o <<  } ;     return o;   }   using A3 = array<long long, 3>;   inline long long get(long long x, long long i) {     return (x & (63LL << (i * 6))) >> (i * 6);   }   inline long long se(long long x, long long i, long long w) {     long long sh = (i * 6);     (x &= ~(63LL << sh)) ^= w << sh;     return x;   }   inline long long del(long long x, long long i) {     long long sh = i * 6;     long long rm = x & ((1LL << sh) - 1);     ((x >>= sh + 6) <<= sh) |= rm;     return x;   }   A3 dec(long long x) { return {x & 3, (x >> 2) & 3, (x >> 4) & 3}; }   inline long long enc(A3 a) {     if (a[2] > a[0]) swap(a[2], a[0]);     return a[0] + (a[1] << 2) + (a[2] << 4);   }   unordered_map<long long, double> mem;   const double INF = 1e9;   long long norm(long long x) {     static long long Z[30];     long long i = 1, p;     for (; p = get(x, i); i++) {       Z[i] = p;     }     sort(Z + 1, Z + i);     for (long long j = 1; j < i; j++) {       x = se(x, j, Z[j]);     }     return x;   }   long long zz = 0;   double dp(long long st) {     if (mem.count(st)) return mem[st];     double ex[4] = {0, INF, INF, INF};     for (long long i = 1, p; p = get(st, i); i++) {       auto a = dec(p);       if (!a[1] or (!a[0] and !a[2])) continue;       for (long long j = 0; j < 3; j++) {         if (!a[j]) continue;         if (a[2] == 0 and j == 1) continue;         long long cl = a[j];         auto b = a;         b[j] = 0;         long long nx;         if (!b[1] or (!b[0] and !b[2])) {           nx = del(st, i);         } else {           nx = se(st, i, enc(b));         }         long long top = get(nx, 0);         auto c = dec(top);         if (c[0] and c[1] and c[2]) {           top <<= 6;           nx <<= 6;           c = dec(top);         }         for (long long k = 0; k < 3; k++)           if (!c[k]) {             auto d = c;             d[k] = cl;             long long fn = norm(se(nx, 0, enc(d)));             ex[cl] = min(ex[cl], dp(fn));           }       }     }     if (ex[1] >= INF and ex[2] >= INF and ex[3] >= INF) {       return (mem[st]) = 0;     } else {       double zzprob = 1.0 / 6;       if (ex[1] == INF) zzprob += 1.0 / 6, ex[1] = 0;       if (ex[2] == INF) zzprob += 2.0 / 6, ex[2] = 0;       if (ex[3] == INF) zzprob += 2.0 / 6, ex[3] = 0;       (mem[st]) = (ex[1] * 1.0 / 6 + ex[2] * 2.0 / 6 + ex[3] * 2.0 / 6 + 1) /                   (1.0 - zzprob);       return (mem[st]);     }   }   int32_t main() {     do {       ios_base::sync_with_stdio(0);       cin.tie(0);     } while (0);     long long N;     cin >> N;     cout << fixed << setprecision(10);     long long t = 0;     for (long long i = 0; i < N; i++) {       string s;       cin >> s;       A3 a;       for (long long j = 0; j < 3; j++) {         long long z = s[j] ==  R  ? 1 : s[j] ==  G  ? 2 : 3;         a[j] = z;       }       (t <<= 6) += enc(a);     }     cout << dp(t) << endl;     return 0;   }   