#include <bits/stdc++.h>
using namespace std;
vector<int> incl[100];
bool avail[100][100010];
int n, ok[100][100010], num[10], use[100010], one[100];
bool test(int p, int tag) {
  for (auto x : incl[tag]) {
    int tot = 0;
    for (auto y : incl[x]) {
      tot += ok[y][p + 1] * ((one[y]) ? 1 : -1);
    }
    int tmp = x;
    for (int i = 0; i < 6; i++) {
      if (tmp & 1) {
        tot -= num[i];
        if (tot < 0) return false;
      }
      tmp >>= 1;
    }
  }
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  for (int i = 1; i < 64; i++) one[i] = (one[i >> 1] + (i & 1)) & 1;
  for (int i = 1; i < 64; i++)
    for (int j = i; j < 64; j++)
      if ((i | j) == j) incl[j].push_back(i);
  string s;
  cin >> s;
  n = s.size();
  for (int p = 0; p < n; p++) num[s[p] - 'a']++;
  int tag = 0;
  for (int i = 0; i < 6; i++)
    if (num[i]) tag += (1 << i);
  int m;
  cin >> m;
  while (m--) {
    int p;
    cin >> p;
    p--;
    string st;
    cin >> st;
    int cur = 0;
    for (int i = 0; i < st.size(); i++) use[p] += 1 << (st[i] - 'a');
    for (auto x : incl[use[p]]) avail[x][p] = true;
  }
  for (int p = 0; p < n; p++)
    if (!use[p]) {
      use[p] = 63;
      for (int j = 1; j < 64; j++) avail[j][p] = true;
    }
  for (int j = 1; j < 64; j++)
    for (int p = n - 1; p >= 0; p--) ok[j][p] = ok[j][p + 1] + avail[j][p];
  bool tf = true;
  string ans = s;
  for (int p = 0; tf && p < n; p++) {
    tf = false;
    for (int j = 0; j < 6; j++)
      if (avail[1 << j][p] && (num[j] > 0)) {
        ans[p] = 'a' + j;
        num[j]--;
        if (num[j] == 0) tag -= (1 << j);
        if (test(p, tag)) {
          tf = true;
          break;
        }
        num[j]++;
        if (num[j] == 1) tag += (1 << j);
      }
  }
  if (!tf)
    cout << "Impossible\n";
  else
    cout << ans << "\n";
}
