#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
using namespace std;
template <class T>
inline T bigmod(T p, T e, T M) {
  long long ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  }
  return (T)ret;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T modinverse(T a, T M) {
  return bigmod(a, M - 2, M);
}
template <class T>
inline T lcm(T a, T b) {
  a = abs(a);
  b = abs(b);
  return (a / gcd(a, b)) * b;
}
template <class T, class X>
inline bool getbit(T a, X i) {
  T t = 1;
  return ((a & (t << i)) > 0);
}
template <class T, class X>
inline T setbit(T a, X i) {
  T t = 1;
  return (a | (t << i));
}
template <class T, class X>
inline T resetbit(T a, X i) {
  T t = 1;
  return (a & (~(t << i)));
}
inline long long getnum() {
  char c = getchar();
  long long num, sign = 1;
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') sign = -1;
  for (num = 0; c >= '0' && c <= '9';) {
    c -= '0';
    num = num * 10 + c;
    c = getchar();
  }
  return num * sign;
}
inline long long power(long long a, long long b) {
  long long multiply = 1;
  for (int i = (0); i < (b); i++) {
    multiply *= a;
  }
  return multiply;
}
string s;
int occ[6], p, q, n, N[100005][64];
bool graph[100005][6];
void calcSubset() {
  for (int i = (0); i < (n); i++) {
    for (int j = (0); j < (64); j++) {
      bool flag = false;
      for (int k = (0); k < (6); k++) {
        if (j & (1 << k)) {
          if (graph[i][k]) {
            flag = true;
            break;
          }
        }
      }
      N[i][j] += flag;
      if (i) N[i][j] += N[i - 1][j];
    }
  }
}
bool canBuildSuffix(int pos) {
  for (int i = (0); i < (64); i++) {
    int val = 0;
    for (int j = (0); j < (6); j++) {
      if (i & (1 << j)) val += occ[j];
    }
    if (val > N[n - 1][i] - N[pos - 1][i]) return false;
  }
  return true;
}
void solve() {
  for (int i = (0); i < (n); i++) {
    int t = 0;
    for (int j = (0); j < (6); j++)
      if (graph[i][j]) t++;
    if (t == 0)
      for (int j = (0); j < (6); j++) graph[i][j] = true;
  }
  calcSubset();
  string ans = "";
  for (int i = (0); i < (n); i++) {
    for (int j = (0); j < (6); j++) {
      if (!graph[i][j] || occ[j] == 0) continue;
      occ[j]--;
      if (canBuildSuffix(i + 1)) {
        ans += char(j + 'a');
        break;
      }
      occ[j]++;
    }
  }
  if (ans.size() < n)
    cout << "Impossible"
         << "\n";
  else
    cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  int test, cases = 1;
  cin >> s;
  for (int i = (0); i < (s.size()); i++) {
    occ[s[i] - 'a']++;
  }
  n = s.size();
  cin >> q;
  while (q--) {
    cin >> p >> s;
    for (int i = (0); i < (s.size()); i++) graph[p - 1][s[i] - 'a'] = true;
  }
  solve();
  return 0;
}
