#include <bits/stdc++.h>
using namespace std;
long long n, m, s[7];
long long lin[100005][1 << 7], cov[1 << 7];
char ch[100005], ans[100005];
vector<long long> e[100005];
bool hall(long long x) {
  for (long long ss = 0; ss <= (1 << 6) - 1; ss++) {
    long long sum = 0;
    for (long long i = 1; i <= 6; i++)
      if (ss >> i - 1 & 1) sum += s[i];
    if (lin[x][ss] < sum) return 0;
  }
  return 1;
}
signed main() {
  scanf("%s", ch + 1);
  n = strlen(ch + 1);
  for (long long i = 1; i <= n; i++) s[ch[i] - 'a' + 1]++;
  cin >> m;
  for (long long i = 1, p; i <= m; i++) {
    string pat;
    cin >> p >> pat;
    for (long long j = 0; j < pat.length(); j++)
      e[p].push_back(pat[j] - 'a' + 1), cov[p] |= 1 << pat[j] - 'a';
  }
  for (long long i = 1; i <= n; i++)
    if (e[i].size() == 0) {
      cov[i] = (1 << 6) - 1;
      for (long long j = 1; j <= 6; j++) e[i].push_back(j);
    }
  for (long long i = n; i >= 1; i--) {
    for (long long s = 0; s <= (1 << 6) - 1; s++)
      if (s & cov[i])
        lin[i][s] = lin[i + 1][s] + 1;
      else
        lin[i][s] = lin[i + 1][s];
  }
  for (long long i = 1; i <= n; i++) {
    sort(e[i].begin(), e[i].end());
    for (long long j = 0; j < e[i].size(); j++) {
      s[e[i][j]]--;
      if (hall(i + 1)) {
        ans[i] = (char)(e[i][j] + 'a' - 1);
        break;
      }
      s[e[i][j]]++;
    }
  }
  if (strlen(ans + 1) < n) return puts("Impossible"), 0;
  for (long long i = 1; i <= n; i++) cout << ans[i];
  return puts(""), 0;
}
