#include <bits/stdc++.h>
using namespace std;
int n, m, sl, fh, flg, c[100010], cnt[1 << 6], f[100010][1 << 6];
char ch, s[100010], ans[100010];
int rd() {
  sl = 0;
  fh = 1;
  ch = getchar();
  while (ch < '0' || '9' < ch) {
    if (ch == '-') fh = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') sl = sl * 10 + ch - '0', ch = getchar();
  return sl * fh;
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < 1 << 6; ++j)
      if (j & (1 << (s[i] - 'a'))) cnt[j]++;
  }
  for (int i = 1; i <= n; ++i) c[i] = (1 << 6) - 1;
  m = rd();
  for (int x, l, i = 1; i <= m; ++i) {
    x = rd();
    c[x] = 0;
    scanf("%s", s + 1);
    l = strlen(s + 1);
    for (int j = 1; j <= l; ++j) c[x] |= 1 << (s[j] - 'a');
  }
  for (int i = n; i; --i)
    for (int j = 0; j < 1 << 6; ++j) {
      f[i][j] = f[i + 1][j];
      if ((j & c[i]) == c[i]) f[i][j]++;
    }
  for (int i = 1; i <= n; ++i) {
    flg = 0;
    for (int x, j = 0; j < 6; ++j)
      if (cnt[1 << j] && ((c[i] >> j) & 1)) {
        x = 1;
        for (int k = 0; x && k < 1 << 6; ++k)
          if (f[i + 1][k] > cnt[k] - ((k >> j) & 1)) x = 0;
        if (x) {
          flg = 1;
          ans[i] = 'a' + j;
          for (int k = 0; k < 1 << 6; ++k)
            if ((k >> j) & 1) cnt[k]--;
        }
      }
    if (!flg) {
      puts("Impossible");
      return 0;
    }
  }
  puts(ans + 1);
  return 0;
}
