#include <bits/stdc++.h>
using namespace std;
int get() {
  char ch;
  while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-')
    ;
  if (ch == '-') {
    int s = 0;
    while (ch = getchar(), ch >= '0' && ch <= '9') s = s * 10 + ch - '0';
    return -s;
  }
  int s = ch - '0';
  while (ch = getchar(), ch >= '0' && ch <= '9') s = s * 10 + ch - '0';
  return s;
}
const int N = 1e5 + 5;
int n;
char s[N];
int can[N];
int f[60], g[60];
char ans[N];
void add(int w, int x, int v) {
  x = (1 << x);
  for (int i = 0; i <= (1 << 6) - 1; i++)
    if ((x & i) > 0) f[i] += v;
  for (int i = 0; i <= (1 << 6) - 1; i++)
    if ((can[w] & i) > 0) g[i] += v;
}
bool possible() {
  bool ret = 1;
  for (int i = 0; i <= (1 << 6) - 1; i++) ret &= (f[i] <= g[i]);
  return ret;
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; i++) can[i] = (1 << 6) - 1;
  for (int m = get(); m; m--) {
    int x = get();
    char cv[10];
    scanf("%s", cv + 1);
    can[x] = 0;
    for (int j = 1; j <= strlen(cv + 1); j++) can[x] |= (1 << (cv[j] - 'a'));
  }
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= (1 << 6) - 1; j++)
      if ((can[i] & j) > 0) g[j]++;
  for (int i = 1; i <= n; i++) {
    int now = (1 << (s[i] - 'a'));
    for (int j = 0; j <= (1 << 6) - 1; j++)
      if ((now & j) > 0) f[j]++;
  }
  if (!possible()) return printf("Impossible\n"), 0;
  for (int i = 1; i <= n; i++) {
    for (int x = 0; x <= 5; x++)
      if (((can[i] & (1 << x)) > 0)) {
        add(i, x, -1);
        if (possible()) {
          ans[i] = 'a' + x;
          break;
        }
        add(i, x, 1);
      }
  }
  for (int i = 1; i <= n; i++) putchar(ans[i]);
  putchar('\n');
  return 0;
}
