#include <bits/stdc++.h>
using namespace std;
using namespace std;
inline int read() {
  char ch;
  bool sign = 0;
  int res = 0;
  while (!isdigit(ch = getchar()))
    if (ch == '-') sign = 1;
  while (isdigit(ch)) res = res * 10 + (ch ^ 48), ch = getchar();
  if (sign)
    return -res;
  else
    return res;
}
const int maxn = 100000 + 10;
const long long inf = 68721573904;
const int MAXM = 3;
const int MOD[MAXM] = {469762049, 998244353, 1004535809};
const int mod = 998244353;
const int maxm = 6;
char s[maxn];
int suf[maxn][1 << maxm];
int dp[maxn][1 << maxm];
int can[maxn];
int n, m;
int has[maxm];
inline int check(int p) {
  for (auto i = (0); i < (1 << maxm); ++i) {
    int now = 0;
    for (auto j = (0); j < (maxm); ++j) now += (((1 << j) & i) >> j) * has[j];
    if (now < dp[p][i]) return 0;
  }
  return 1;
}
inline int solve() {
  string t;
  for (auto i = (1); i <= (n); ++i) has[s[i] - 'a']++;
  for (auto i = (1); i <= (n); ++i) {
    for (auto j = (0); j < (maxm); ++j) {
      if (!((1 << j) & can[i])) continue;
      has[j]--;
      if (!check(i + 1))
        has[j]++;
      else {
        t.push_back(j + 'a');
        break;
      }
    }
    if (t.length() != i) return 0;
  }
  printf("%s", t.c_str());
  return 1;
}
int main(void) {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  scanf("%d", &(m));
  for (auto i = (1); i <= (n); ++i)
    suf[i][(1 << 6) - 1]++, can[i] = (1 << 6) - 1;
  for (auto i = (1); i <= (m); ++i) {
    int p;
    char t[10];
    scanf("%d %s", &p, t);
    int now = 0;
    for (int j = 0; t[j]; ++j) now |= (1 << (t[j] - 'a'));
    suf[p][now]++;
    suf[p][(1 << 6) - 1]--;
    can[p] = now;
  }
  for (auto i = (n); i >= (1); --i) {
    for (auto j = (0); j < (1 << 6); ++j) {
      suf[i][j] += suf[i + 1][j];
      for (int k = j; k > 0; k = (k - 1) & j) {
        dp[i][j] += suf[i][k];
      }
    }
  }
  solve() ? puts("") : puts("Impossible");
  return 0;
}
