#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int n, m, sz[maxn], link[maxn][1 << 6], x, cover[maxn];
char s[maxn], ans[maxn];
vector<int> t[maxn];
bool check(int x) {
  for (int i = 0; i < 1 << 6; i++) {
    int a = link[x][i], b = 0;
    for (int j = 0; j < 6; j++)
      if ((i >> j) & 1) b += sz[j];
    if (a < b) return 0;
  }
  return 1;
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; i++) sz[s[i] - 'a']++;
  cin >> m;
  for (int i = 1; i <= m; i++) {
    scanf("%d%s", &x, s + 1);
    int len = strlen(s + 1);
    for (int j = 1; j <= len; j++)
      t[x].push_back(s[j] - 'a'), cover[x] += 1 << (s[j] - 'a');
  }
  for (int i = 1; i <= n; i++)
    if (t[i].size() == 0) {
      cover[i] = (1 << 6) - 1;
      for (int j = 'a'; j <= 'f'; j++) t[i].push_back(j - 'a');
    }
  for (int i = n; i >= 1; i--) {
    for (int j = 0; j < 1 << 6; j++)
      if (j & cover[i])
        link[i][j] = link[i + 1][j] + 1;
      else
        link[i][j] = link[i + 1][j];
  }
  for (int i = 1; i <= n; i++) {
    sort(t[i].begin(), t[i].end());
    for (auto c : t[i]) {
      sz[c]--;
      if (check(i + 1)) {
        ans[i] = c + 'a';
        break;
      }
      sz[c]++;
    }
  }
  if (strlen(ans + 1) < n)
    cout << "Impossible";
  else
    printf("%s", ans + 1);
}
