#include <bits/stdc++.h>
const int maxn = 1E+5 + 5;
int n, m, lim[maxn];
char s[maxn];
int cnt[6], tim[64];
inline bool check() {
  for (int i = 1; i < 64; ++i) {
    int tot = 0;
    for (int j = 0; j < 6; ++j)
      if (i >> j & 1) tot += cnt[j];
    if (tot > tim[i]) return false;
  }
  return true;
}
inline void GT(int S, int v) {
  for (int T = 1; T < 64; ++T)
    if (S & T) tim[T] += v;
}
int main() {
  scanf("%s%d", s + 1, &m), n = strlen(s + 1);
  std::fill(lim + 1, lim + n + 1, 63);
  for (int i = 1; i <= m; ++i) {
    int p;
    char c[10];
    scanf("%d%s", &p, c);
    int r = strlen(c);
    lim[p] = 0;
    for (int j = 0; j < r; ++j) lim[p] |= 1 << c[j] - 'a';
  }
  for (int i = 1; i <= n; ++i) ++cnt[s[i] - 'a'], GT(lim[i], 1);
  if (!check()) return puts("Impossible"), 0;
  for (int i = 1; i <= n; ++i) {
    GT(lim[i], -1);
    for (int j = 0; j < 6; ++j)
      if (lim[i] >> j & 1) {
        --cnt[j];
        if (check()) {
          putchar('a' + j);
          break;
        }
        ++cnt[j];
      }
  }
}
