func_code_string: #include <bits/stdc++.h>   using namespace std;   map<string, int> g;   bool can;   int n, i;   char s[100][5];   void find(int x) {     char temp[10];     string ss;     int j;     if (x == 1) {       can = true;       return;     }     if ((s[x][0] == s[x - 1][0]) || (s[x][1] == s[x - 1][1])) {       strcpy(temp, s[x - 1]);       strcpy(s[x - 1], s[x]);       ss.clear();       for (j = 1; j <= x - 1; j++) ss = ss + s[j];       if (g[ss] == 0) {         g[ss] = 1;         find(x - 1);       }       strcpy(s[x - 1], temp);     }     if (x > 3)       if ((s[x][0] == s[x - 3][0]) || s[x][1] == s[x - 3][1]) {         strcpy(temp, s[x - 3]);         strcpy(s[x - 3], s[x]);         for (j = 1; j <= x - 1; j++) ss = ss + s[j];         if (g[ss] == 0) {           g[ss] = 1;           find(x - 1);         }         strcpy(s[x - 3], temp);       }   }   int main() {     can = false;     cin >> n;     g.clear();     memset(s, 0, sizeof(s));     for (i = 1; i <= n; i++) scanf( %s , s[i]);     find(n);     if (can)       cout <<  YES  << endl;     else       cout <<  NO  << endl;   }   