func_code_string: #include <bits/stdc++.h>   using namespace std;   int ns[(1 << 6)];   int s[(1 << 6)];   char str[100005];   int p[100005];   void solve() {     int n;     scanf( %s  , str + 1);     n = strlen(str + 1);     for (int i = n; i; --i) {       int al = str[i] -  a ;       for (int bit = 0; bit < (1 << 6); ++bit) {         if (bit & (1 << al)) {           ns[bit]++;         }       }       p[i] = (1 << 6) - 1;     }     int m;     scanf( %d  , &m);     for (int i = 1; i <= m; ++i) {       int pos;       scanf( %d  , &pos);       scanf( %s  , &str);       int len = strlen(str);       p[pos] = 0;       for (int j = 0; j < len; ++j) {         p[pos] |= (1 << (str[j] -  a ));       }     }     for (int i = n; i; --i) {       for (int bit = 0; bit < (1 << 6); ++bit) {         if ((bit & (p[i])) == p[i]) {           ++s[bit];         }       }     }     for (int bit = 0; bit < (1 << 6); ++bit) {       if (s[bit] > ns[bit]) {         printf( Impossible n );         return;       }     }     for (int i = 1; i <= n; ++i) {       int curAl = -1;       for (int al = 0; al < 6 && curAl == -1; ++al) {         if ((1 << al) & p[i]) {           bool isGood = true;           for (int bit = 0; bit < (1 << 6) && isGood; ++bit) {             int tns = ns[bit], ts = s[bit];             if ((bit & (p[i])) == p[i]) {               --ts;             }             if (bit & (1 << al)) {               --tns;             }             if (ts > tns) {               isGood = false;             }           }           if (isGood) {             curAl = al;           }         }       }       assert(curAl != -1);       for (int bit = 0; bit < (1 << 6); ++bit) {         if ((bit & (p[i])) == p[i]) {           --s[bit];         }       }       for (int bit = 0; bit < (1 << 6); ++bit) {         if (bit & (1 << curAl)) {           --ns[bit];         }       }       putchar( a  + curAl);     }     putchar(  n );   }   int main() {     solve();     return 0;   }   