#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int a[N];
int cnt[N];
int need[N];
int n, m;
int getbit(int x, int i) { return (x >> i) & 1; }
void add(int x, int val) {
  for (int mask = 0; mask < (1 << 6); mask++)
    if (getbit(mask, x)) cnt[mask] += val;
}
bool check() {
  for (int mask = 0; mask < (1 << 6); mask++)
    if (cnt[mask] < need[mask]) return false;
  return true;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  for (char c : s) add(c - 'a', 1);
  n = s.size();
  for (int i = 1; i <= n; i++) a[i] = 63;
  cin >> m;
  for (int i = 1; i <= m; i++) {
    int id;
    string t;
    cin >> id >> t;
    int mask = 0;
    for (char c : t) mask |= (1 << (c - 'a'));
    a[id] = mask;
  }
  for (int i = 1; i <= n; i++) need[a[i]]++;
  for (int i = 0; i < 6; i++)
    for (int mask = 0; mask < (1 << 6); mask++)
      if (getbit(mask, i)) need[mask] += need[mask ^ (1 << i)];
  string ans;
  for (int i = 1; i <= n; i++) {
    bool found = false;
    for (int mask = 0; mask < (1 << 6); mask++)
      if ((mask & a[i]) == a[i]) need[mask]--;
    for (int j = 0; j <= 5; j++)
      if (getbit(a[i], j)) {
        add(j, -1);
        if (check()) {
          ans += (char)j + 'a';
          found = true;
          break;
        }
        add(j, 1);
      }
    if (!found) {
      ans = "Impossible";
      break;
    }
  }
  cout << ans;
  return 0;
}
