func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<vector<int> > g, tr, comp;   vector<int> us, vis, whr, col;   void dfs(int v) {     us[v] = 1;     for (int i = 0; i < g[v].size(); i++) {       int j = g[v][i];       if (!us[j]) dfs(j);     }     vis.push_back(v);     return;   }   void dfstr(int v) {     comp[comp.size() - 1].push_back(v);     whr[v] = comp.size() - 1;     us[v] = 1;     for (int i = 0; i < tr[v].size(); i++) {       int j = tr[v][i];       if (!us[j]) dfstr(j);     }     return;   }   void doit(int v, int c) {     us[v] = 1;     if ((v & 1) ^ c)       col[v / 2] = 1;     else       col[v / 2] = 0;     for (int i = 0; i < g[v].size(); i++) {       int j = g[v][i];       if (!us[j]) doit(j, c);     }     return;   }   int main() {     iostream::sync_with_stdio(0);     cin.tie(0), cout.tie(0);     int n;     cin >> n;     vector<string> all(n);     vector<pair<string, string> > add(n);     for (int i = 0; i < n; i++) {       string s, c;       cin >> s >> c;       all[i] = s.substr(0, 2);       add[i].first = s.substr(2, 1);       add[i].second = c.substr(0, 1);     }     g.resize(2 * n);     tr.resize(2 * n);     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if (i == j) continue;         if (all[i] + add[i].first == all[j] + add[j].first) {           g[2 * i].push_back(2 * j + 1);           g[2 * j].push_back(2 * i + 1);           tr[2 * j + 1].push_back(2 * i);           tr[2 * i + 1].push_back(2 * j);           g[2 * i + 1].push_back(2 * j + 1);           g[2 * j + 1].push_back(2 * i + 1);           tr[2 * i + 1].push_back(2 * j + 1);           tr[2 * j + 1].push_back(2 * i + 1);         }         if (all[i] + add[i].first == all[j] + add[j].second) {           g[2 * i].push_back(2 * j);           g[2 * j + 1].push_back(2 * i + 1);           tr[2 * j].push_back(2 * i);           tr[2 * i + 1].push_back(2 * j + 1);         }         if (all[i] + add[i].second == all[j] + add[j].second) {           g[2 * i + 1].push_back(2 * j);           g[2 * j + 1].push_back(2 * i);           tr[2 * j].push_back(2 * i + 1);           tr[2 * i].push_back(2 * j + 1);         }         if (all[i] + add[i].second == all[j] + add[j].first) {           g[2 * i + 1].push_back(2 * j + 1);           g[2 * j].push_back(2 * i);           tr[2 * j + 1].push_back(2 * i + 1);           tr[2 * i].push_back(2 * j);         }       }     }     us.resize(2 * n, 0);     for (int i = 0; i < 2 * n; i++) {       if (!us[i]) {         dfs(i);       }     }     us.assign(2 * n, 0);     whr.resize(2 * n);     for (int i = 2 * n - 1; i >= 0; i--) {       int x = vis[i];       if (!us[x]) {         comp.emplace_back(vector<int>());         dfstr(x);       }     }     for (int i = 0; i < n; i++) {       if (whr[2 * i] == whr[2 * i + 1]) {         cout <<  NO n ;         return 0;       }     }     col.resize(n);     us.assign(2 * n, 0);     reverse(comp.begin(), comp.end());     for (int i = 0; i < comp.size(); i++) {       for (int j = 0; j < comp[i].size(); j++) {         if (!us[comp[i][j]]) doit(comp[i][j], 1);       }     }     cout <<  YES n ;     for (int i = 0; i < n; i++) {       cout << all[i] << (col[i] == 0 ? add[i].first : add[i].second) <<   n ;     }     return 0;   }   