#include <bits/stdc++.h>
using namespace std;
int tot[26];
int match[8][65];
int vis[105];
int dfs(int a) {
  for (int i = 0; i < 6; i++) {
    if ((1 << i) & a) {
      if (tot[i]) {
        tot[i]--;
        match[i][a]++;
        return i;
      } else {
        for (int j = 0; j < 65; j++) {
          if (match[i][j] && !vis[j]) {
            vis[j] = 1;
            if (dfs(j) != -1) {
              match[i][j]--;
              match[i][a]++;
              return i;
            }
          }
        }
      }
    }
  }
  return -1;
}
int main() {
  char c[100005];
  scanf("%s", c);
  for (int i = 0; c[i] != 0; i++) {
    tot[c[i] - 'a']++;
  }
  int len = strlen(c);
  int num[100005];
  fill(num, num + len, 63);
  int m;
  scanf("%d", &m);
  while (m--) {
    int pos;
    char cc[10];
    scanf("%d %s", &pos, cc);
    int sum = 0;
    for (int i = 0; cc[i] != 0; i++) {
      sum |= (1 << (cc[i] - 'a'));
    }
    num[pos - 1] = sum;
  }
  for (int i = 0; i < len; i++) {
    memset(vis, 0, sizeof(vis));
    int first = dfs(num[i]);
    if (first == -1) {
      printf("Impossible\n");
      return 0;
    }
  }
  for (int i = 0; i < len; i++) {
    for (int j = 0; j < 8; j++) {
      if (match[j][num[i]]) {
        match[j][num[i]]--;
        tot[j]++;
        break;
      }
    }
    memset(vis, 0, sizeof(vis));
    int first = dfs(num[i]);
    printf("%c", first + 'a');
    match[first][num[i]]--;
  }
  return 0;
}
