#include <bits/stdc++.h>
using namespace std;
char s[110000], ans[110000];
int rs[70], G[110000][64], E[110000];
inline int read() {
  int n = 0;
  char a;
  bool z = false;
  while (a = getchar()) {
    if (a > '9' || a < '0')
      if (z)
        break;
      else
        continue;
    if (!z) z = true;
    n = (n << 1) + (n << 3) + (a ^ 48);
  }
  return n;
}
int main() {
  scanf("%s", s + 1);
  int m = strlen(s + 1), n = read(), len, x;
  for (int i = 1; i <= m; ++i) ++rs[1 << s[i] - 'a'];
  for (int S = 0; S < 64; ++S)
    if (S & S - 1) rs[S] = rs[S & S - 1] + rs[S & -S];
  for (int i = 1; i <= n; ++i) {
    x = read();
    scanf("%s", s + 1);
    len = strlen(s + 1);
    for (int j = 1; j <= len; ++j) E[x] |= 1 << s[j] - 'a';
  }
  for (int i = 1; i <= m; ++i)
    if (!E[i]) E[i] = 63;
  for (int i = m; i; --i)
    for (int S = 0; S < 64; ++S) G[i][S] = G[i + 1][S] + (S & E[i] ? 1 : 0);
  for (int i = 1; i <= m; ++i) {
    bool zz = false;
    for (int j = 1; j <= 6; ++j) {
      if (!rs[1 << j - 1] || !(E[i] & 1 << j - 1)) continue;
      bool Z = true;
      for (int S = 0; S < 64; ++S)
        if (G[i + 1][S] < rs[S] - (S & 1 << j - 1 ? 1 : 0)) {
          Z = false;
          break;
        }
      if (Z) {
        ans[i] = j + 'a' - 1;
        zz = true;
        for (int S = 0; S < 64; ++S) rs[S] -= S & 1 << j - 1 ? 1 : 0;
        break;
      }
    }
    if (!zz) return !printf("Impossible");
  }
  printf("%s", ans + 1);
  return 0;
}
