#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int cnt[6], n, m, sum[N][64], g[64], h[64];
bool bz[N], ok[N][64];
char S[N], T[N];
int main() {
  scanf("%s%d", S + 1, &m);
  n = strlen(S + 1);
  for (int i = 1; i <= n; i++) cnt[S[i] -= 'a']++;
  for (int y, x; m--;) {
    scanf("%d%s", &x, T);
    y = strlen(T);
    y = strlen(T);
    bz[x] = 1;
    for (int i = 0; i < y; i++) ok[x][T[i] - 'a'] = 1;
  }
  for (int i = 1; i <= n; i++)
    if (!bz[i]) {
      for (int j = 0; j < 6; j++) ok[i][j] = 1;
    }
  for (int i = n; i; i--) {
    int s = 0;
    for (int j = 0; j < 6; j++) s |= (ok[i][j] << j);
    for (int j = 0; j < 64; j++) {
      sum[i][j] = sum[i + 1][j];
      if ((j & s) == s) sum[i][j]++;
    }
  }
  for (int j, i = 1; i <= n; i++) {
    for (j = 0; j < 6; j++)
      if (cnt[j] && ok[i][j]) {
        bool bz = 1;
        cnt[j]--;
        for (int k = 0; k < 6; k++) g[1 << k] = cnt[k];
        for (int k = 1; k < 64; k++) {
          g[k] = g[k ^ (k & -k)] + g[k & -k];
          if (g[k] < sum[i + 1][k]) {
            bz = 0;
            break;
          }
        }
        if (bz) {
          putchar('a' + j);
          break;
        }
        cnt[j]++;
      }
    if (j == 6) {
      puts("Impossible");
      return 0;
    }
  }
  puts("");
  return 0;
}
