#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int f[N][1 << 6], mask[N], cnt[1 << 6];
char s[N], ans[N];
int main() {
  scanf("%s", s + 1);
  int 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++) mask[i] = (1 << 6) - 1;
  int m;
  scanf("%d", &m);
  int x;
  char s1[10];
  while (m--) {
    scanf("%d%s", &x, s1);
    mask[x] = 0;
    for (int i = 0; s1[i]; i++) mask[x] |= (1 << (s1[i] - 'a'));
  }
  for (int i = n; i; i--)
    for (int j = 0; j < (1 << 6); j++) {
      f[i][j] = f[i + 1][j];
      if ((j & mask[i]) == mask[i]) f[i][j]++;
    }
  for (int i = 1; i <= n; i++) {
    bool found = false;
    for (int j = 0; j < 6; j++)
      if ((1 << j) & mask[i]) {
        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) {
          found = true;
          ans[i] = 'a' + j;
          for (int k = 0; k < (1 << 6); k++)
            if (k & (1 << j)) cnt[k]--;
        }
      }
    if (!found) {
      puts("Impossible");
      return 0;
    }
  }
  puts(ans + 1);
}
