#include <bits/stdc++.h>
using namespace std;
int n, st[100010], t[6], g[1 << 6];
char c[100010], ans[100010];
int main() {
  scanf("%s", c + 1);
  n = strlen(c + 1);
  for (int i = 1; i <= n; i++) t[c[i] - 'a']++, st[i] = (1 << 6) - 1;
  int q, x;
  scanf("%d", &q);
  while (q--) {
    scanf("%d%s", &x, c);
    int p = 0;
    for (int i = 0; i < strlen(c); i++) p |= (1 << (c[i] - 'a'));
    st[x] &= p;
  }
  for (int i = 1; i <= n; i++)
    for (int s = 0; s < (1 << 6); s++)
      if (st[i] & s) g[s]++;
  bool fll = 1;
  for (int i = 1; i <= n; i++) {
    for (int s = 0; s < (1 << 6); s++)
      if (st[i] & s) g[s]--;
    bool fx = 0;
    for (int j = 0; j < 6; j++)
      if (t[j] && ((st[i] >> j) & 1)) {
        t[j]--;
        bool fl = 1;
        for (int s = 0; s < (1 << 6); s++) {
          int sp = 0;
          for (int k = 0; k < 6; k++)
            if ((s >> k) & 1) sp += t[k];
          fl &= (g[s] >= sp);
        }
        if (fl) {
          fx = 1;
          ans[i] = j + 'a';
          break;
        }
        t[j]++;
      }
    fll &= fx;
  }
  if (!fll)
    puts("Impossible");
  else
    for (int i = 1; i <= n; i++) printf("%c", ans[i]);
  return 0;
}
