#include <bits/stdc++.h>
using namespace std;
char s[101010], tmp[6];
int m;
vector<int> avail[101010];
int mask[101010];
int n;
int suf[101010][64];
int cnt[6];
int ans[101010];
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  scanf("%d", &m);
  for (int i = 1, p; i <= m; ++i) {
    scanf("%d %s", &p, tmp);
    int len = strlen(tmp);
    for (int i = 0; i < len; ++i) {
      avail[p].emplace_back(tmp[i] - 'a');
      mask[p] |= (1 << (tmp[i] - 'a'));
    }
  }
  for (int i = 1; i <= n; ++i) {
    cnt[s[i] - 'a']++;
    if (mask[i]) continue;
    mask[i] = 63;
    for (int j = 0; j < 6; ++j) avail[i].emplace_back(j);
  }
  for (int i = n; i >= 1; --i) {
    for (int j = 0; j < 64; ++j) {
      suf[i][j] = suf[i + 1][j] + !!(mask[i] & j);
    }
  }
  memset(ans, 0xff, sizeof ans);
  for (int i = 1; i <= n; ++i) {
    sort(avail[i].begin(), avail[i].end());
    for (int c : avail[i]) {
      cnt[c]--;
      for (int j = 0; j < 64; ++j) {
        int a = suf[i + 1][j], b = 0;
        for (int k = 0; k < 6; ++k) b += ((j >> k) & 1) * cnt[k];
        if (a < b) goto nextchoice;
      }
      ans[i] = c;
      break;
    nextchoice:;
      cnt[c]++;
    }
    if (!~ans[i]) {
      puts("Impossible");
      return 0;
    }
  }
  for (int i = 1; i <= n; ++i) putchar('a' + ans[i]);
}
