#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
const int oo = 1e9;
const int MX = 100000000;
string s;
int pos, freq[6], sk[1 << 7], al[N];
char tmp[8];
bool perfectMatch() {
  bool broke = false;
  for (int msk = 0; msk < (1 << 6); ++msk) {
    int res = 0;
    for (int j = 0; j < 6; ++j)
      if ((msk & (1 << j)) > 0) res += freq[j];
    broke = broke || (res > sk[msk]);
  }
  return !broke;
}
void add(int me, int val) {
  for (int ms = 0; ms < (1 << 6); ++ms) {
    if ((ms & me) > 0) sk[ms] += val;
  }
}
int main() {
  cin >> s;
  for (int i = 0; i < s.size(); ++i) freq[s[i] - 'a']++;
  int m;
  cin >> m;
  for (int a, i = 0; i < m; ++i) {
    scanf("%d%s", &pos, tmp);
    for (int j = 0; j < strlen(tmp); ++j) al[pos] |= (1 << (tmp[j] - 'a'));
  }
  for (int i = 1; i <= s.size(); ++i)
    if (!al[i]) al[i] = 127;
  for (int i = 1; i <= s.size(); ++i) add(al[i], 1);
  string res = "";
  for (int i = 1; i <= s.size(); ++i) {
    char ch = 'z';
    add(al[i], -1);
    for (int j = 'a'; j <= 'f'; ++j) {
      if ((al[i] & (1 << (j - 'a'))) == 0) continue;
      freq[j - 'a']--;
      if (perfectMatch()) {
        ch = j;
        break;
      }
      freq[j - 'a']++;
    }
    if (ch == 'z') {
      puts("Impossible");
      return 0;
    } else {
      res += ch;
    }
  }
  cout << res << endl;
  return 0;
}
