#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
template <typename Tp>
int getmin(Tp &x, Tp y) {
  return y < x ? x = y, 1 : 0;
}
template <typename Tp>
int getmax(Tp &x, Tp y) {
  return y > x ? x = y, 1 : 0;
}
template <typename Tp>
void read(Tp &x) {
  x = 0;
  char ch = getchar();
  int f = 0;
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') ch = getchar(), f = 1;
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  if (f) x = -x;
}
int n, m, st[maxn], f[maxn][64], now[64];
char s[maxn], ans[maxn];
void input() {
  int p, tmp;
  char t[10];
  scanf("%s", s + 1);
  n = strlen(s + 1);
  read(m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j < 64; j++)
      if (j & (1 << (s[i] - 'a'))) ++now[j];
  for (int i = 1; i <= m; i++) {
    read(p);
    scanf("%s", t + 1);
    tmp = 0;
    for (int j = 1; t[j]; j++) tmp |= (1 << (t[j] - 'a'));
    st[p] = tmp;
  }
  for (int i = n; i; i--) {
    if (!st[i]) st[i] = 63;
    for (int j = 1; j < 64; j++) {
      f[i][j] = f[i + 1][j];
      if (j & st[i]) ++f[i][j];
    }
  }
}
int main() {
  input();
  for (int i = 1; i <= n; i++) {
    for (int j = 0, fg; j < 6; j++)
      if (st[i] & (1 << j)) {
        fg = 1;
        for (int s = 1; s < 64; s++) {
          int tmp = now[s];
          if (s & (1 << j)) tmp--;
          if (f[i + 1][s] < tmp) {
            fg = 0;
            break;
          }
        }
        if (fg) {
          for (int s = 1; s < 64; s++)
            if (s & (1 << j)) --now[s];
          ans[i] = 'a' + j;
          break;
        }
      }
    if (!ans[i]) {
      puts("Impossible");
      return 0;
    }
  }
  puts(ans + 1);
  return 0;
}
