#include <bits/stdc++.h>
using namespace std;
const int MAXL = 100010;
const int INF = 0x3f3f3f3f;
char str[MAXL];
int mask[MAXL], cnt_mask[1 << 6], cnt_ch[6];
int source, sink, tot = 1;
const int MAXN = 400;
const int MAXM = 400000;
int to[MAXM], _next[MAXM], head[MAXN], cap[MAXM], num[400][400];
int pre[MAXN], cur[MAXN];
bool vis[MAXN];
void addEdge(int u, int v, int c) {
  to[++tot] = v, _next[tot] = head[u], cap[tot] = c, head[u] = tot;
  num[u][v] = tot;
}
int DFS(int u, int mmin) {
  if (u == sink || mmin == 0) return mmin;
  int flow = 0, f;
  for (int &i = cur[u]; i; i = _next[i]) {
    int v = to[i];
    if (pre[v] == pre[u] + 1 && (f = DFS(v, min(mmin, cap[i]))) > 0) {
      flow += f, cap[i] -= f, cap[i ^ 1] += f, mmin -= f;
      if (mmin == 0) break;
    }
  }
  return flow;
}
bool BFS() {
  queue<int> q;
  q.push(source);
  memset(vis, false, sizeof(vis));
  vis[source] = true;
  pre[source] = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = head[u]; i; i = _next[i]) {
      int v = to[i];
      if (vis[v] || !cap[i]) continue;
      pre[v] = pre[u] + 1, vis[v] = true;
      q.push(v);
    }
  }
  return vis[sink];
}
int maxFlow() {
  int flow = 0;
  while (BFS()) {
    memcpy(cur, head, sizeof(head));
    flow += DFS(source, INF);
  }
  return flow;
}
bool check(int mask, int c) {
  if (!(mask & (1 << c))) return false;
  int cv = c + 1, mv = mask + 6;
  int ce = num[source][cv], me = num[mv][sink];
  if (cap[ce ^ 1] == 0) return false;
  cap[ce]++, cap[ce ^ 1]--;
  vector<int> aff_edge;
  aff_edge.push_back(ce);
  for (int i = head[cv]; i; i = _next[i])
    if (i % 2 == 0 && cap[i ^ 1] != 0) {
      int x = to[i];
      cap[i]++, cap[i ^ 1]--;
      aff_edge.push_back(i);
      for (int j = head[x]; j; j = _next[j])
        if (j % 2 == 0 && cap[j ^ 1] != 0) {
          cap[j]++, cap[j ^ 1]--;
          aff_edge.push_back(j);
          break;
        }
      break;
    }
  if (cap[me]) {
    cap[ce]--;
    cap[me]--;
    return true;
  }
  cap[me]++, cap[me ^ 1]--;
  aff_edge.push_back(me);
  for (int i = head[mv]; i; i = _next[i])
    if (i % 2 == 1 && cap[i] != 0) {
      int x = to[i];
      cap[i]--, cap[i ^ 1]++;
      aff_edge.push_back(i ^ 1);
      for (int j = head[x]; j; j = _next[j])
        if (j % 2 == 1 && cap[j] != 0) {
          cap[j]--, cap[j ^ 1]++;
          aff_edge.push_back(j ^ 1);
          break;
        }
      break;
    }
  cap[ce]--, cap[me]--;
  if (BFS()) {
    memcpy(cur, head, sizeof(head));
    if (DFS(source, 1)) return true;
  }
  cap[ce]++, cap[me]++;
  int ln = aff_edge.size();
  for (int i = 0; i < ln; i++) {
    int e = aff_edge[i];
    cap[e]--, cap[e ^ 1]++;
  }
  return false;
}
int main() {
  scanf("%s", str + 1);
  int n = strlen(str + 1);
  for (int i = 1; i <= n; i++) mask[i] = (1 << 6) - 1;
  int m;
  scanf("%d", &m);
  int idx;
  char sel[10];
  for (int i = 1; i <= m; i++) {
    scanf("%d%s", &idx, sel);
    mask[idx] = 0;
    for (int j = 0; sel[j]; j++) mask[idx] |= (1 << (sel[j] - 'a'));
  }
  for (int i = 1; i <= n; i++) {
    cnt_mask[mask[i]]++;
    cnt_ch[str[i] - 'a']++;
  }
  source = 0, sink = 6 + (1 << 6);
  for (int i = 1; i <= 6; i++) {
    addEdge(source, i, cnt_ch[i - 1]);
    addEdge(i, source, 0);
  }
  for (int i = 1; i <= 6; i++)
    for (int j = 1; j < (1 << 6); j++)
      if ((1 << (i - 1)) & j) {
        addEdge(i, j + 6, INF);
        addEdge(j + 6, i, 0);
      }
  for (int j = 1; j < (1 << 6); j++) {
    addEdge(j + 6, sink, cnt_mask[j]);
    addEdge(sink, j + 6, cnt_mask[j]);
  }
  if (maxFlow() != n) {
    printf("Impossible\n");
    return 0;
  }
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < 6; j++)
      if (check(mask[i], j)) {
        printf("%c", j + 'a');
        break;
      }
}
