#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
char s[N];
int cnt[1 << 7];
int match[N];
int need[1 << 7];
int n, m;
bool judge() {
  for (int i = 0; i < 64; i++) {
    if (need[i] < cnt[i]) return 0;
  }
  return 1;
}
void remove(int pos, int ch) {
  for (int mask = 0; mask < 64; mask++) {
    if (mask & (1 << ch)) {
      cnt[mask]--;
    }
    if (mask & match[pos]) {
      need[mask]--;
    }
  }
}
void add(int pos, int ch) {
  for (int mask = 0; mask < 64; mask++) {
    if (mask & (1 << ch)) {
      cnt[mask]++;
    }
    if (mask & match[pos]) {
      need[mask]++;
    }
  }
}
int ans[N];
int main() {
  cin >> s;
  n = strlen(s);
  for (int i = 0; i < n; i++) {
    cnt[1 << (s[i] - 'a')]++;
  }
  for (int mask = 1; mask < 64; mask++) {
    for (int sub = 1; sub < mask; sub++) {
      if ((sub & mask) == sub) {
        cnt[mask] = cnt[sub] + cnt[mask ^ sub];
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    match[i] = 63;
  }
  cin >> m;
  int p;
  char str[10];
  for (int i = 1; i <= m; i++) {
    scanf("%d%s", &p, str);
    int l = strlen(str);
    int mask = 0;
    for (int j = 0; j < l; j++) {
      mask |= 1 << (str[j] - 'a');
    }
    match[p] &= mask;
  }
  for (int mask = 0; mask < 64; mask++) {
    for (int i = 1; i <= n; i++) {
      if (mask & match[i]) {
        need[mask]++;
      }
    }
  }
  if (!judge()) {
    cout << "Impossible" << endl;
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 6; j++) {
      if (match[i] & (1 << j)) {
        remove(i, j);
        if (judge()) {
          ans[i] = j;
          break;
        } else {
          add(i, j);
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << (char)(ans[i] + 'a');
  }
}
