#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
char s[N], ans[N];
int n, cnt[1 << 6], f[N][1 << 6], edge[N], m;
inline void init() {
  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++) {
    edge[i] = (1 << 6) - 1;
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    char S[10];
    int x;
    scanf("%d %s", &x, S + 1);
    int len = strlen(S + 1);
    edge[x] = 0;
    for (int j = 1; j <= len; j++) {
      edge[x] |= 1 << (S[j] - 'a');
    }
  }
}
inline void solve() {
  for (int i = n; i; i--) {
    for (int j = 0; j < (1 << 6); j++) {
      f[i][j] = f[i + 1][j];
      if ((j & edge[i])) f[i][j]++;
    }
  }
  bool ok = 0;
  for (int i = 1; i <= n; i++) {
    bool flag = false;
    for (int j = 0; j < 6 && !flag; j++) {
      if (cnt[1 << j] && (edge[i] & (1 << j))) {
        ok = 1;
        for (int k = 0; k < (1 << 6) && ok; k++) {
          if (cnt[k] - ((k >> j) & 1) > f[i + 1][k]) {
            ok = false;
          }
        }
        if (ok) {
          flag = 1;
          ans[i] = 'a' + j;
          for (int k = 0; k < (1 << 6); k++) {
            if (k & (1 << j)) cnt[k]--;
          }
        }
      }
    }
    if (!flag) {
      puts("Impossible");
      return;
    }
  }
  puts(ans + 1);
}
int main() {
  init();
  solve();
  return 0;
}
