#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
constexpr int A = 6;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  int N = S.size();
  vec<int> cnt(A);
  for (int i = 0; i < A; i++) cnt[i] = count(S.begin(), S.end(), (char)'a' + i);
  int M;
  cin >> M;
  vec<string> T(N, "abcdef");
  vec<int> flag(N);
  vec<int> restriction(1 << A);
  for (int i = 0; i < M; i++) {
    int id;
    string t;
    cin >> id >> t;
    sort(t.begin(), t.end());
    id--;
    T[id] = t;
    int X = 0;
    for (auto& c : t) X ^= (1 << (c - 'a'));
    flag[id] = X;
    restriction[X]++;
  }
  for (int i = 0; i < A; i++) {
    for (int X = 0; X < (1 << A); X++)
      if (X >> i & 1) restriction[X] += restriction[X ^ (1 << i)];
  }
  string ans = "";
  auto check = [&](char c) {
    for (int X = 0; X < (1 << A); X++) {
      int c0 = 0;
      for (int i = 0; i < A; i++)
        if (X >> i & 1) {
          c0 += cnt[i];
        }
      if (X >> (c - 'a') & 1) c0--;
      if (c0 < restriction[X]) return false;
    }
    return true;
  };
  for (int i = 0; i < N; i++) {
    bool ok = false;
    if (flag[i])
      for (int X = 0; X < (1 << A); X++)
        if ((flag[i] & X) == flag[i]) restriction[X]--;
    for (auto& c : T[i])
      if (cnt[c - 'a']) {
        if (check(c)) {
          ok = true;
          ans += c;
          cnt[c - 'a']--;
          break;
        }
      }
    if (!ok) {
      cout << "Impossible\n";
      return 0;
    }
  }
  cout << ans << "\n";
}
