#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 10;
int n, m;
char str[N], ans[N];
int cnt[1 << 6], edge[N], f[N][1 << 6];
char tmp[10];
int main() {
  scanf("%s", str + 1);
  n = strlen(str + 1);
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < (1 << 6); j++)
      if (j & (1 << (str[i] - 'a'))) cnt[j]++;
  for (int i = 1; i <= n; i++) edge[i] = (1 << 6) - 1;
  scanf("%d", &m);
  for (int i = 1, x; i <= m; i++) {
    scanf("%d %s", &x, tmp);
    int k = strlen(tmp);
    edge[x] = 0;
    for (int j = 0; j < k; j++) edge[x] += 1 << (tmp[j] - 'a');
  }
  for (int i = n; i >= 1; i--)
    for (int j = 0; j < (1 << 6); j++) {
      f[i][j] = f[i + 1][j];
      if ((j & edge[i]) == edge[i]) f[i][j]++;
    }
  for (int i = 1; i <= n; i++) {
    bool find = false;
    for (int j = 0; j < 6 && !find; j++)
      if (cnt[1 << j] && (edge[i] & (1 << j))) {
        bool ok = true;
        for (int k = 0; k < (1 << 6) && ok; k++)
          if (f[i + 1][k] > cnt[k] - ((k >> j) & 1)) ok = false;
        if (ok) {
          find = true;
          ans[i] = 'a' + j;
          for (int k = 0; k < (1 << 6); k++)
            if (k & (1 << j)) cnt[k]--;
        }
      }
    if (!find) {
      puts("Impossible\n");
      return 0;
    }
  }
  puts(ans + 1);
  return 0;
}
