func_code_string: #include <bits/stdc++.h>   using namespace std;   bool isgood(const vector<vector<char> > &graph, const vector<char> &choice) {     int n = (int)graph.size() / 2;     assert((int)graph[0].size() == 2 * n);     assert((int)choice.size() == n);     for (int i = 0; i < n; i++) {       bool ok = false;       int lbound = 2 * i;       int rbound = 2 * i + 1;       if (choice[i] != -1) lbound = rbound = 2 * i + choice[i];       for (int who = lbound; who <= rbound; who++) {         bool cur = true;         for (int j = 0; j < n; j++) {           if (choice[j] != -1 && graph[who][2 * j + 1 - choice[j]]) cur = false;           if (graph[who][2 * j] && graph[who][2 * j + 1]) cur = false;         }         ok |= cur;       }       if (!ok) return false;     }     return true;   }   void solve(string alph) {     int n, m;     cin >> n >> m;     vector<vector<char> > graph(2 * n, vector<char>(2 * n));     int pos1, pos2;     char t1, t2;     for (int i = 0; i < m; i++) {       scanf(  %d %c %d %c , &pos1, &t1, &pos2, &t2);       int x1 = 2 * (pos1 - 1) + (t1 ==  V  ? 0 : 1);       int x2 = 2 * (pos2 - 1) + (t2 ==  V  ? 0 : 1);       graph[x1][x2] = 1;       graph[x2 ^ 1][x1 ^ 1] = 1;     }     string word;     cin >> word;     assert((int)word.size() == n);     for (int i = 0; i < 2 * n; i++) graph[i][i] = 1;     for (int k = 0; k < 2 * n; k++)       for (int i = 0; i < 2 * n; i++)         for (int j = 0; j < 2 * n; j++)           graph[i][j] |= (graph[i][k] & graph[k][j]);     for (int i = 0; i < 2 * n; i++)       if (graph[i][i ^ 1] && graph[i ^ 1][i]) {         puts( -1 );         return;       }     vector<char> choice(n, -1);     for (int i = 0; i < n; i++) choice[i] = (alph[word[i] -  a ] ==  V  ? 0 : 1);     vector<int> next_vowel(alph.size() + 1, -1), next_cons(alph.size() + 1, -1);     for (int i = 0; i < (int)alph.size(); i++) {       for (int j = i; j < (int)alph.size(); j++) {         if (alph[j] ==  V  && next_vowel[i] == -1) next_vowel[i] = j;         if (alph[j] ==  C  && next_cons[i] == -1) next_cons[i] = j;       }     }     if (isgood(graph, choice)) {       puts(word.c_str());       return;     }     int lcp;     for (lcp = n - 1; lcp > 0; lcp--) {       int num = word[lcp] -  a  + 1;       if (next_vowel[num] != -1) {         choice[lcp] = 0;         if (isgood(graph, choice)) break;       }       if (next_cons[num] != -1) {         choice[lcp] = 1;         if (isgood(graph, choice)) break;       }       choice[lcp] = -1;     }     choice[lcp] = -1;     string ans = word.substr(0, lcp);     for (int i = lcp; i < n; i++) {       char start = (i == lcp ? word[i] + 1 :  a );       bool was_vowel = false;       bool was_cons = false;       bool ok = false;       for (char ch = start; ch <  a  + (int)alph.size(); ch++) {         if (!was_vowel && alph[ch -  a ] ==  V ) {           was_vowel = true;           choice[i] = 0;           ok |= isgood(graph, choice);           if (ok) {             ans += ch;             break;           }         }         if (!was_cons && alph[ch -  a ] ==  C ) {           was_cons = true;           choice[i] = 1;           ok |= isgood(graph, choice);           if (ok) {             ans += ch;             break;           }         }       }       if (!ok) {         puts( -1 );         return;       }     }     puts(ans.c_str());   }   int main() {     string n;     while (cin >> n) solve(n);   }   