func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 405;   char mp[30], s[N], a[5], b[5];   int L, n, m, e[N][N], nxd[30], nxs[30], flg[30], lim[N], tmp[N], mx[2];   vector<int> ans;   bool chk(int pos, int v, int x, bool ff) {     if (lim[pos] != -1 && lim[pos] != flg[v]) return 0;     for (int i = 1; i <= n; i++)       if (e[x][i] && e[x][i + n]) return 0;     for (int i = 1; i <= n; i++) tmp[i] = (e[x][i] ? 0 : (e[x][i + n] ? 1 : -1));     if (ff) {       for (int i = 1; i <= n; i++) {         if (pos + i > n) break;         int t = max(lim[pos + i], tmp[pos + i]);         if (t == -1) break;         if (mx[t] < s[pos + i] -  a  + 1) return 0;         if (mx[t] > s[pos + i] -  a  + 1) break;       }     }     for (int i = 1; i <= n; i++) {       lim[i] = max(lim[i], tmp[i]);     }     return 1;   }   int main() {     scanf( %s , mp + 1);     L = strlen(mp + 1);     memset(lim, -1, sizeof(lim));     memset(mx, -1, sizeof(mx));     for (int i = 1; i <= L; i++) {       flg[i] = mp[i] ==  V ;       mx[flg[i]] = i;     }     for (int i = 1; i <= L; i++)       for (int j = i + 1; j <= L; j++)         if (flg[i] != flg[j]) {           nxd[i] = j;           break;         }     for (int i = 1; i <= L; i++)       for (int j = i + 1; j <= L; j++)         if (flg[i] == flg[j]) {           nxs[i] = j;           break;         }     cin >> n >> m;     for (int i = 1; i <= m; i++) {       int x, y;       scanf( %d%s%d%s , &x, a, &y, b);       int a1 = a[0] ==  V , b1 = b[0] ==  V ;       e[x + a1 * n][y + b1 * n] = 1;       e[y + !b1 * n][x + !a1 * n] = 1;     }     scanf( %s , s + 1);     for (int k = 1; k <= n * 2; k++)       for (int i = 1; i <= n * 2; i++)         for (int j = 1; j <= n * 2; j++) e[i][j] |= (e[i][k] & e[k][j]);     bool ff = 1;     for (int i = 1; i <= n; i++) {       int mn = ff ? s[i] -  a  + 1 : 1;       if (chk(i, mn, i + flg[mn] * n, ff)) {         ans.push_back(mn);       } else if (mn < L && flg[mn] == flg[mn + 1] &&                  chk(i, mn + 1, i + flg[mn + 1] * n, 0)) {         ans.push_back(mn + 1), ff = 0;       } else if (nxd[mn] && chk(i, nxd[mn], i + flg[nxd[mn]] * n, 0)) {         ans.push_back(nxd[mn]), ff = 0;       } else if (nxs[mn] && nxs[mn] > nxd[mn] &&                  chk(i, nxs[mn], i + flg[nxs[mn]] * n, 0)) {         ans.push_back(nxs[mn]), ff = 0;       } else {         return puts( -1 ), 0;       }     }     for (int i = 0; i <= n - 1; i++) printf( %c , ans[i] +  a  - 1);     puts(  );     return 0;   }   