#include <bits/stdc++.h>
using ll = long long;
template <class t, class u, class... w>
auto operator<<(t& o, u a) -> decltype(a.print(a), o) {
  return o << "{", a.print(), o << "}";
}
using namespace std;
void DD(...) {}
using Pii = pair<int, int>;
template <class t, class u, class... w>
void DD(t s, u a, w... k) {
  while (*s && *s != ',') cerr << *s++;
  cerr << ": " << a << *s++;
  DD(s, k...);
}
template <class t, class u, class... w>
auto operator<<(t& o, u a) -> decltype((a).begin(), (a).end(), o) {
  return o << "[",
         [&]() {
           for (auto i : a) o << i << ", ";
         }(),
         o << "]";
}
using Vi = vector<int>;
template <class t, class u, class... w>
auto operator<<(t& o, u a) -> decltype(get<1>(a), o) {
  return o << "(" << a.first << ", " << a.second << ")";
}
constexpr int ALPHA = 6;
constexpr int APOW = 1 << ALPHA;
int counts[ALPHA], hall[APOW];
Vi masks;
bool isHall() {
  for (int mask = (0); mask < (APOW); mask++) {
    int first = 0;
    for (int i = (0); i < (ALPHA); i++)
      if (mask & (1 << i)) first += counts[i];
    if (first > hall[mask]) return false;
  }
  return true;
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(10);
  string str;
  cin >> str;
  for (auto& c : (str)) counts[c - 'a']++;
  masks.resize(str.size(), APOW - 1);
  int n;
  cin >> n;
  while (n--) {
    int i;
    cin >> i >> str;
    i--;
    masks[i] = 0;
    for (auto& c : (str)) masks[i] |= 1 << (c - 'a');
  }
  for (int mask = (0); mask < (APOW); mask++)
    for (auto& opt : (masks))
      if (opt & mask) hall[mask]++;
  if (!isHall()) {
    cout << "Impossible\n";
    return 0;
  }
  for (int i = (0); i < (int((masks).size())); i++) {
    int opt = masks[i];
    for (int mask = (0); mask < (APOW); mask++)
      if (opt & mask) hall[mask]--;
    for (int chr = (0); chr < (ALPHA); chr++)
      if (counts[chr] > 0 && (masks[i] & (1 << chr))) {
        counts[chr]--;
        if (isHall()) {
          cout << char('a' + chr);
          break;
        }
        counts[chr]++;
      }
  }
  return 0;
}
