#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, M = (1 << 6);
int s[N], b[N][M], a[N], nm[M], c[N], zt[M], tot;
char lx[N];
bool check(int id, int ch) {
  for (int i = 0; i <= tot; ++i) {
    int pos = zt[i];
    if ((i >> ch) & 1) {
      pos--;
    }
    if (pos > b[id][i]) {
      return false;
    }
  }
  return true;
}
void fail() {
  puts("Impossible");
  exit(0);
}
int main() {
  scanf("%s", lx + 1);
  int n = strlen(lx + 1);
  for (int i = 1; i <= n; ++i) {
    int pos = lx[i] - 'a';
    nm[pos]++;
  }
  tot = (1 << 6) - 1;
  for (int i = 1; i <= n; ++i) s[i] = tot;
  int m;
  scanf("%d", &m);
  for (int i = 1, x; i <= m; ++i) {
    scanf("%d", &x);
    scanf("%s", lx + 1);
    int len = strlen(lx + 1);
    s[x] = 0;
    for (int j = 1; j <= len; ++j) {
      int pos = lx[j] - 'a';
      s[x] |= (1 << pos);
    }
  }
  for (int i = n; i >= 1; --i) {
    for (int j = 0; j <= tot; ++j) {
      b[i][j] = b[i + 1][j];
      if (s[i] & j) b[i][j]++;
    }
  }
  for (int j = 0; j <= tot; ++j)
    for (int i = 0; i < 6; ++i) {
      if ((j >> i) & 1) zt[j] += nm[i];
    }
  for (int i = 1; i <= n; ++i) {
    bool flg = false;
    for (int j = 0; j < 6; ++j) {
      if (nm[j] && ((s[i] >> j) & 1) && check(i + 1, j)) {
        flg = true;
        nm[j]--;
        c[i] = j;
        break;
      }
    }
    if (!flg) fail();
    for (int j = 0; j <= tot; ++j) {
      zt[j] = 0;
      for (int k = 0; k < 6; ++k)
        if ((j >> k) & 1) zt[j] += nm[k];
    }
  }
  for (int i = 1; i <= n; ++i) {
    printf("%c", c[i] + 'a');
  }
  puts("");
  return 0;
}
