#include <bits/stdc++.h>
using namespace std;
int n;
int cnt[6];
int bms[100005];
int reqs[1 << 6];
bool chk() {
  for (int i = 0; i < (signed)(1 << 6); i++) {
    int amt = 0;
    for (int j = 0; j < (signed)(6); j++)
      if (i & (1 << j)) amt += cnt[j];
    if (amt < reqs[i]) return false;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string second;
  cin >> second;
  n = second.length();
  for (int i = 0; i < (signed)(n); i++) cnt[second[i] - 'a']++;
  int m;
  cin >> m;
  for (int i = 0; i < (signed)(m); i++) {
    int x;
    string t;
    cin >> x >> t;
    int bm = 0;
    for (int j = 0; j < (signed)(t.length()); j++) {
      bm += 1 << (t[j] - 'a');
    }
    bms[x] = bm;
  }
  for (int i = (1); i <= (signed)(n); i++) {
    if (bms[i] == 0) bms[i] = 63;
    for (int j = 0; j < (signed)(1 << 6); j++) {
      if ((bms[i] & j) == bms[i]) {
        ++reqs[j];
      }
    }
  }
  if (!chk()) {
    cout << "Impossible\n";
    return 0;
  }
  string ans = "";
  for (int i = (1); i <= (signed)(n); i++) {
    int cbm = bms[i];
    for (int j = 0; j < (signed)(1 << 6); j++)
      if ((cbm & j) == cbm) --reqs[j];
    for (int j = 0; j < (signed)(6); j++)
      if ((cbm & (1 << j)) && cnt[j] != 0) {
        --cnt[j];
        if (chk()) {
          ans += (char)('a' + j);
          break;
        }
        ++cnt[j];
      }
  }
  cout << ans << "\n";
  return 0;
}
