func_code_string: #include <bits/stdc++.h>   using namespace std;   int count = 0;   bool YES = false;   vector<string> record;   int compare(vector<string> cards, int pile1, int pile2) {     if (cards.at(pile1)[0] == cards.at(pile2)[0] ||         cards.at(pile1)[1] == cards.at(pile2)[1])       return 1;     return 0;   }   void move(vector<string> cards) {     int N = cards.size();     int end = N - 1;     if (N >= 4) {       if (compare(cards, end, end - 3)) {         string str =   ;         for (int k = 0; k < cards.size(); k++) {           str += cards.at(k);         }         for (int k = 0; k < record.size(); k++) {           if (str == record.at(k)) return;         }         record.push_back(str);         vector<string> cards_t = cards;         cards_t.at(end - 3) = cards_t.at(end);         cards_t.pop_back();         move(cards_t);         if (YES) return;       }       if (compare(cards, end, end - 1)) {         vector<string> cards_t = cards;         cards_t.at(end - 1) = cards_t.at(end);         cards_t.pop_back();         move(cards_t);         if (YES) return;       }     } else if (N > 1) {       if (compare(cards, end, end - 1)) {         vector<string> cards_t = cards;         cards_t.at(end - 1) = cards_t.at(end);         cards_t.pop_back();         move(cards_t);         if (YES) return;       }     } else if (N == 1) {       YES = true;       return;     }     return;   }   int main() {     vector<string> cards;     int t;     string card;     cin >> t;     for (int i = 0; i < t; i++) {       cin >> card;       cards.push_back(card);     }     move(cards);     if (YES)       cout <<  YES  << endl;     else       cout <<  NO  << endl;     return 0;   }   