#include <bits/stdc++.h>
const int INF = 0x3f3f3f3f;
struct edge {
  int a, b, cap, flow;
  edge() {}
  edge(int a_, int b_, int cap_, int flow_) {
    a = a_;
    b = b_;
    cap = cap_;
    flow = flow_;
  }
};
const int N = 100000;
const int A = 6;
const int M = 1 << A;
const int V = 2 + A + M;
int mask[N];
int mask_amt[M];
char s[N + 1];
int n, m;
int amt[A];
int e_size = 0;
edge e[2 * (M * A + M + A)];
std::vector<int> g[V];
int ind[V][V];
bool u[V];
void add_edge(int a, int b, int cap) {
  ind[a][b] = e_size;
  g[a].push_back(e_size);
  e[e_size++] = edge(a, b, cap, 0);
  g[b].push_back(e_size);
  e[e_size++] = edge(b, a, 0, 0);
}
int dfs(int v, int val = INF) {
  u[v] = true;
  if (v == V - 1) return val;
  for (int i = 0; i < (int)g[v].size(); ++i)
    if (e[g[v][i]].cap > e[g[v][i]].flow && !u[e[g[v][i]].b]) {
      int d =
          dfs(e[g[v][i]].b, std::min(val, e[g[v][i]].cap - e[g[v][i]].flow));
      if (d) {
        e[g[v][i]].flow += d;
        e[g[v][i] ^ 1].flow -= d;
        return d;
      }
    }
  return 0;
}
int run_dfs() {
  memset(u, 0, V * sizeof(bool));
  return dfs(0);
}
void dec_flow(const std::vector<int> &path) {
  for (int i = 0; i < (int)path.size(); ++i) {
    --e[path[i]].flow;
    ++e[path[i] ^ 1].flow;
  }
}
void inc_flow(const std::vector<int> &path) {
  for (int i = 0; i < (int)path.size(); ++i) {
    ++e[path[i]].flow;
    --e[path[i] ^ 1].flow;
  }
}
void dec_cap(const std::vector<int> &path) {
  for (int i = 0; i < (int)path.size(); ++i) --e[path[i]].cap;
}
std::vector<int> from(int x) {
  std::vector<int> path;
  path.push_back((x - 1) * 2);
  int v = x;
  int i;
  for (int k = 0; k < 2; ++k) {
    for (i = 0; e[g[v][i]].flow <= 0; ++i)
      ;
    path.push_back(g[v][i]);
    v = e[g[v][i]].b;
  }
  return path;
}
std::vector<int> to(int x) {
  bool ok = false;
  for (int i = 0; !ok; ++i)
    if (((1 << i) & (x - A - 1)) && e[g[0][i]].flow > 0) {
      int v = e[g[0][i]].b;
      int j;
      for (j = 0; j < (int)g[v].size() && !ok; ++j)
        if (e[g[v][j]].b == x && e[g[v][j]].flow > 0) ok = true;
      if (ok) {
        --j;
        std::vector<int> path = {g[0][i], g[v][j], g[x].back()};
        return path;
      }
    }
  return std::vector<int>();
}
int main() {
  scanf("%s", s);
  n = strlen(s);
  scanf("%d", &m);
  std::fill(mask, mask + n, M - 1);
  for (int i = 0; i < m; ++i) {
    int pos;
    char t[A + 1];
    scanf("%d%s", &pos, t);
    --pos;
    int letter = 0;
    for (int j = 0; t[j]; ++j) letter = letter | (1 << (t[j] - 'a'));
    mask[pos] &= letter;
  }
  for (int i = 0; i < n; ++i) ++mask_amt[mask[i]];
  for (int i = 0; i < n; ++i) ++amt[s[i] - 'a'];
  for (int i = 0; i < A; ++i) add_edge(0, i + 1, amt[i]);
  for (int i = 0; i < M; ++i)
    for (int j = 0; j < A; ++j)
      if (i & (1 << j)) add_edge(1 + j, 1 + A + i, INF);
  for (int i = 0; i < M; ++i) add_edge(1 + A + i, V - 1, mask_amt[i]);
  int flow = 0;
  int add = 0;
  while (add = run_dfs()) flow += add;
  if (flow != n) {
    printf("Impossible\n");
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    bool set = false;
    for (int j = 0; j < A && !set; ++j)
      if (e[j * 2].cap && (mask[i] & (1 << j))) {
        std::vector<int> path = {ind[0][1 + j], ind[1 + j][1 + A + mask[i]],
                                 ind[1 + A + mask[i]][V - 1]};
        bool ok = true;
        for (int i = 0; i < 3; ++i)
          if (!e[path[i]].flow) ok = false;
        if (ok) {
          dec_flow(path);
          dec_cap(path);
          set = true;
        } else {
          std::vector<int> path1 = from(1 + j);
          std::vector<int> path2 = to(1 + A + mask[i]);
          dec_flow(path1);
          dec_flow(path2);
          --e[ind[0][1 + j]].cap;
          --e[ind[1 + A + mask[i]][V - 1]].cap;
          add = run_dfs();
          if (add)
            set = true;
          else {
            inc_flow(path1);
            inc_flow(path2);
            ++e[ind[0][1 + j]].cap;
            ++e[ind[1 + A + mask[i]][V - 1]].cap;
          }
        }
        if (set) printf("%c", 'a' + j);
      }
  }
  printf("\n");
  return 0;
}
