#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int edges[N];
int cnt[1 << 6];
int f[N][1 << 6];
int main() {
  string str;
  cin >> str;
  int n = str.size();
  for (int i = 0; i < n; i += 1) {
    for (int j = 0; j < (1 << 6); j += 1) {
      if (j & (1 << (str[i] - 'a'))) cnt[j] += 1;
    }
    edges[i] = (1 << 6) - 1;
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; i += 1) {
    int p;
    string pos;
    cin >> p >> pos;
    p -= 1;
    edges[p] = 0;
    for (int j = 0; j < pos.size(); j += 1) {
      edges[p] |= 1 << (pos[j] - 'a');
    }
  }
  for (int i = n - 1; i >= 0; i -= 1) {
    for (int j = 0; j < (1 << 6); j += 1) {
      f[i][j] = f[i + 1][j];
      if ((edges[i] & j) == edges[i]) f[i][j] += 1;
    }
  }
  string ans(n, '0');
  for (int i = 0; i < n; i += 1) {
    bool find = false;
    for (int j = 0; j < 6 && !find; j += 1) {
      if ((1 << j) & edges[i]) {
        bool flag = true;
        for (int k = 0; k < (1 << 6) && flag; k += 1) {
          if (f[i + 1][k] > cnt[k] - ((k >> j) & 1)) {
            flag = false;
          }
        }
        if (flag) {
          find = true;
          ans[i] = 'a' + j;
          for (int k = 0; k < (1 << 6); k += 1) cnt[k] -= (k >> j) & 1;
        }
      }
    }
    if (!find) {
      cout << "Impossible" << endl;
      return 0;
    }
  }
  cout << ans << endl;
}
