#include <bits/stdc++.h>
using namespace std;
const int fullmask = (1 << 6) - 1;
char s[100005], buf[10];
int n, m;
int ok[100005];
int tmp[1 << 6], need[1 << 6], have[1 << 6], c[6];
inline bool doit(int mask, int ch) {
  for (int i = 1; i < (1 << 6); ++i)
    if (!((i | mask) ^ i)) {
      --need[i];
    }
  for (int i = 1; i < (1 << 6); ++i)
    if (i >> ch & 1) --have[i];
  for (int i = 1; i < (1 << 6); ++i)
    if (have[i] < need[i]) return 0;
  return 1;
}
inline void redo(int mask, int ch) {
  for (int i = 1; i < (1 << 6); ++i)
    if (!((i | mask) ^ i)) {
      ++need[i];
    }
  for (int i = 1; i < (1 << 6); ++i)
    if (i >> ch & 1) ++have[i];
}
int main() {
  ios::sync_with_stdio(false);
  cin >> s + 1 >> m;
  n = strlen(s + 1);
  for (int i = 1; i <= (n); ++i) ok[i] = fullmask;
  for (int i = 1; i <= (n); ++i) ++c[s[i] - 'a'];
  for (int i = 1; i <= (m); ++i) {
    int pos;
    cin >> pos >> buf;
    int x = strlen(buf);
    ok[pos] = 0;
    for (int j = 0; j < (x); ++j) ok[pos] |= 1 << (buf[j] - 'a');
  }
  for (int i = 1; i <= (n); ++i) ++tmp[ok[i]];
  for (int i = 1; i < (1 << 6); ++i) {
    for (int j = i; j; j = (j - 1) & i) need[i] += tmp[j];
  }
  for (int i = 1; i < (1 << 6); ++i) {
    for (int j = 0; j < 6; ++j)
      if (i & (1 << j)) have[i] += c[j];
  }
  for (int i = 1; i < (1 << 6); ++i)
    if (need[i] > have[i]) {
      cout << "Impossible";
      return 0;
    }
  for (int p = 1; p <= n; ++p) {
    for (int ch = 0; ch < 6; ++ch)
      if (ok[p] >> ch & 1) {
        if (doit(ok[p], ch)) {
          putchar(ch + 'a');
          break;
        } else
          redo(ok[p], ch);
      }
  }
  return 0;
}
