func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, A[6], B[(1 << 6)], C[100001], P[(1 << 6)], Q[(1 << 6)];   char s[100001];   void TakeInputs() {     string s;     cin >> s;     for (auto c : s) {       int i = c -  a ;       ++A[i];     }     n = s.size();     for (int i = 0; i < n; ++i) {       C[i] = (1 << 6) - 1;     }     int m;     cin >> m;     while (m--) {       int i, mask = 0;       cin >> i >> s;       for (auto c : s) {         int j = c -  a ;         mask |= (1 << j);       }       --i;       C[i] = mask;     }     for (int i = 0; i < n; ++i) {       ++B[C[i]];     }   }   bool Check() {     for (int i = 0; i < (1 << 6); ++i) {       P[i] = 0;       Q[i] = B[i];     }     for (int k = 0; k < 6; ++k) {       P[(1 << k)] = A[k];     }     for (int j = 0; j < 6; ++j) {       for (int i = 0; i < (1 << 6); ++i) {         if ((i & (1 << j)) > 0) {           P[i] += P[(i ^ (1 << j))];           Q[i] += Q[(i ^ (1 << j))];         }       }     }     bool ans = 1;     for (int i = 0; i < (1 << 6) && ans == 1; ans = (P[i] >= Q[i]), ++i)       ;     return ans;   }   int main() {     TakeInputs();     for (int i = 0; i < n; ++i) {       for (int k = 0; k < 6; ++k) {         if (A[k] == 0 || s[i] >=  a  || ((1 << k) & C[i]) == 0) {           continue;         }         --A[k];         --B[C[i]];         if (Check()) {           s[i] =  a  + k;         } else {           ++A[k];           ++B[C[i]];         }       }       if (!(s[i] >=  a )) {         break;       }     }     if (strlen(s) == n) {       printf( %s n , s);     } else {       printf( Impossible n );     }     return 0;   }   