#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e6;
const int OO = 0x3f3f3f3f;
const double EPS = 1e-9;
const int S = 70;
const int T = 71;
struct edge {
  int v, c, f;
  edge(int _v, int _c, int _f) : v(_v), c(_c), f(_f) {}
};
vector<edge> edges;
vector<int> G[100];
string str, aux;
int n, idx, cor[MAX], tempo = 1;
int mask[MAX], cntLetter[10], cntMask[70], edge_num[100][100];
void addEdge(int u, int v, int c, int rc) {
  edge_num[u][v] = edges.size();
  G[u].push_back(edges.size());
  edges.push_back(edge(v, c, 0));
  G[v].push_back(edges.size());
  edges.push_back(edge(u, rc, 0));
}
int dfs(int s, int t, int f) {
  if (s == t) return f;
  cor[s] = tempo;
  for (int &e : G[s])
    if (cor[edges[e].v] < tempo and edges[e].c - edges[e].f > 0)
      if (int a = dfs(edges[e].v, t, min(f, edges[e].c - edges[e].f))) {
        edges[e].f += a;
        edges[e ^ 1].f -= a;
        return a;
      }
  return 0;
}
int maxFlow(int s, int t) {
  int mf = 0;
  while (int a = dfs(s, t, OO)) mf += a, tempo++;
  return mf;
}
bool check(int j, int mask) {
  if ((mask & (1 << j)) == 0) return false;
  int e1 = edge_num[S][j];
  int e2 = edge_num[mask + 6][T];
  if (edges[e1].f == 0 or edges[e2].f == 0) return false;
  edges[e1].f--;
  edges[e1 ^ 1].f++;
  vector<int> alterado;
  alterado.push_back(e1);
  for (int &e : G[edges[e1].v]) {
    if (!(e & 1) and edges[e].f > 0) {
      alterado.push_back(e);
      edges[e].f--;
      edges[e ^ 1].f++;
      for (int &ee : G[edges[e].v])
        if (!(ee & 1)) {
          alterado.push_back(ee);
          edges[ee].f--;
          edges[ee ^ 1].f++;
          break;
        }
      break;
    }
  }
  if (edges[e2].f < edges[e2].c) {
    edges[e1].c--;
    edges[e2].c--;
    return true;
  }
  edges[e2].f--;
  edges[e2 ^ 1].f++;
  alterado.push_back(e2);
  for (int &e : G[mask + 6]) {
    if ((e & 1) and edges[e].f < 0) {
      alterado.push_back(e ^ 1);
      edges[e].f++;
      edges[e ^ 1].f--;
      for (int &ee : G[edges[e].v])
        if (ee & 1) {
          alterado.push_back(ee ^ 1);
          edges[ee].f++;
          edges[ee ^ 1].f--;
          break;
        }
      break;
    }
  }
  tempo++;
  edges[e1].c--;
  edges[e2].c--;
  if (dfs(S, T, OO)) return true;
  edges[e1].c++;
  edges[e2].c++;
  for (int &e : alterado) {
    edges[e].f++;
    edges[e ^ 1].f--;
  }
  return false;
}
int main() {
  cin >> str >> n;
  for (int i = 0; i < (int)str.size(); i++) mask[i] = 63;
  for (int i = 0; i < (int)n; i++) {
    cin >> idx >> aux;
    idx--;
    mask[idx] = 0;
    for (char &c : aux) mask[idx] |= (1 << (c - 'a'));
  }
  for (int i = 0; i < (int)str.size(); i++) {
    cntLetter[str[i] - 'a']++;
    cntMask[mask[i]]++;
  }
  for (int i = 0; i < (int)6; i++) addEdge(S, i, cntLetter[i], 0);
  for (int i = 0; i < (int)(1 << 6); i++) addEdge(i + 6, T, cntMask[i], 0);
  for (int i = 0; i < (int)6; i++)
    for (int j = 0; j < (int)(1 << 6); j++)
      if (j & (1 << i)) addEdge(i, j + 6, OO, 0);
  int mf = maxFlow(S, T);
  if (mf != (int)str.size())
    puts("Impossible");
  else {
    for (int i = 0; i < (int)str.size(); i++)
      for (int j = 0; j < (int)6; j++)
        if (check(j, mask[i])) {
          str[i] = char(j + 'a');
          break;
        }
    cout << str << '\n';
  }
  return 0;
}
