#include <bits/stdc++.h>
using namespace std;
const long long oo = 1e18;
const int N = 100005;
const int E = 2000006;
vector<int> g[N];
int ne;
struct Edge {
  int from, to;
  long long flow, cap;
} edge[E];
int lvl[N], vis[N], pass, source = N - 2, target = N - 1;
int qu[N], qt, px[N];
long long run(int s, long long minE) {
  if (s == target) return minE;
  long long ans = 0;
  for (; px[s] < (int)g[s].size(); px[s]++) {
    int e = g[s][px[s]];
    auto &v = edge[e], &rev = edge[e ^ 1];
    if (lvl[v.to] != lvl[s] + 1 || v.flow >= v.cap) continue;
    long long tmp = run(v.to, min(minE, v.cap - v.flow));
    v.flow += tmp, rev.flow -= tmp;
    ans += tmp, minE -= tmp;
    if (minE == 0) break;
  }
  return ans;
}
bool bfs() {
  qt = 0;
  qu[qt++] = source;
  lvl[source] = 1;
  vis[source] = ++pass;
  for (int i = 0; i < qt; i++) {
    int u = qu[i];
    px[u] = 0;
    if (u == target) return true;
    for (int e : g[u]) {
      auto v = edge[e];
      if (v.flow >= v.cap || vis[v.to] == pass) continue;
      vis[v.to] = pass;
      lvl[v.to] = lvl[u] + 1;
      qu[qt++] = v.to;
    }
  }
  return false;
}
long long flow() {
  long long ans = 0;
  while (bfs()) ans += run(source, oo);
  return ans;
}
void addEdge(int u, int v, long long c = 1, long long rc = 0) {
  edge[ne] = {u, v, 0, c};
  g[u].push_back(ne++);
  edge[ne] = {v, u, 0, rc};
  g[v].push_back(ne++);
}
void reset_flow() {
  for (int i = 0; i < ne; i++) edge[i].flow = 0;
}
char s[N];
int m, cnt_letter[300], cnt_bit[1 << 7];
int get_bit() {
  int ans = 0;
  for (int i = 0; s[i]; i++) ans |= 1 << int(s[i] - 'a');
  return ans;
}
int bit[N];
int main() {
  int n;
  scanf("%s", s);
  n = (int)strlen(s);
  for (int i = 0; s[i]; i++) cnt_letter[int(s[i] - 'a')]++;
  scanf("%d", &m);
  for (int i = 0; i < n; i++) bit[i] = (1 << 6) - 1;
  for (int i = 0; i < m; i++) {
    int pos;
    scanf("%d %s", &pos, s);
    pos--;
    bit[pos] = get_bit();
  }
  for (int i = 0; i < n; i++) cnt_bit[bit[i]]++;
  for (int i = 0; i < 6; i++) {
    addEdge(source, i, cnt_letter[i]);
  }
  for (int i = 0; i < 64; i++) {
    addEdge(10 + i, target, cnt_bit[i]);
  }
  for (int i = 0; i < 6; i++)
    if (cnt_letter[i])
      for (int j = 0; j < 64; j++)
        if (cnt_bit[j])
          if ((1 << i) & j) addEdge(i, 10 + j, oo);
  if (flow() < n) return printf("Impossible\n"), 0;
  for (int i = 0; i < n; i++) {
    edge[2 * (6 + bit[i])].cap--;
    for (int j = 0; j < 6; j++)
      if (bit[i] & (1 << j)) {
        if (!edge[2 * j].cap) continue;
        edge[2 * j].cap--;
        reset_flow();
        if (flow() == n - i - 1) {
          s[i] = char(j + 'a');
          break;
        }
        edge[2 * j].cap++;
      }
  }
  s[n] = 0;
  printf("%s\n", s);
}
