#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
const int Mx = 1 << 6;
int n, m;
char s[N], ans[N];
int cnt[Mx], f[N][Mx], e[N];
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < Mx; j++) {
      if (j & (1 << (s[i] - 'a'))) cnt[j]++;
    }
  }
  for (int i = 1; i <= n; i++) e[i] = Mx - 1;
  scanf("%d", &m);
  for (int i = 1, pos, ln; i <= m; i++) {
    scanf("%d%s", &pos, s + 1);
    e[pos] = 0;
    ln = strlen(s + 1);
    for (int j = 1; j <= ln; j++) e[pos] |= 1 << (s[j] - 'a');
  }
  for (int i = n; i; i--) {
    for (int j = 0; j < Mx; j++) {
      f[i][j] += f[i + 1][j];
      if ((j & e[i]) == e[i]) f[i][j]++;
    }
  }
  for (int i = 1, flg, ok; i <= n; i++) {
    flg = 0;
    for (int j = 0; j < 6; j++) {
      if ((e[i] >> j & 1) == 0 || !cnt[1 << j]) continue;
      ok = 1;
      for (int k = 0; k < Mx; k++) {
        if (f[i + 1][k] > cnt[k] - (k >> j & 1)) {
          ok = 0;
          break;
        }
      }
      if (ok) {
        flg = 1;
        ans[i] = j + 'a';
        for (int k = 0; k < Mx; k++)
          if (k >> j & 1) cnt[k]--;
        break;
      }
    }
    if (!flg) return puts("Impossible"), 0;
  }
  puts(ans + 1);
}
