#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 10;
const int MX = 1 << 6;
const int ITS_SO_FUCKING_BIG = 1e9;
int cnt[MX], maskat[MAX], f[6], n, req;
char s[MAX];
template <int SZ>
struct Dinic {
  int N = 0, s, t;
  struct Edge {
    int to, rev;
    int flow, cap;
    int id;
  };
  vector<Edge> adj[SZ];
  void addEdge(int u, int v, int cap, int id = 0) {
    N = max(N, max(u, v) + 1);
    Edge a = {v, (int)adj[v].size(), 0, cap, id},
         b = {u, (int)adj[u].size(), 0, 0, 0};
    adj[u].push_back(a), adj[v].push_back(b);
  }
  int lvl[SZ];
  typename vector<Edge>::iterator cur[SZ];
  bool bfs() {
    for (int i = 0; i < SZ; i++) lvl[i] = -1, cur[i] = adj[i].begin();
    queue<int> q({s});
    lvl[s] = 0;
    while (!q.empty()) {
      int u = q.front();
      q.pop();
      for (auto &e : adj[u])
        if (lvl[e.to] == -1 && e.flow < e.cap) {
          q.push(e.to);
          lvl[e.to] = lvl[u] + 1;
        }
    }
    return lvl[t] >= 0;
  }
  int dfs(int u, int flow) {
    if (u == t || !flow) return flow;
    for (; cur[u] != adj[u].end(); cur[u]++) {
      Edge &e = *cur[u];
      if (lvl[e.to] != lvl[u] + 1 || e.flow == e.cap) continue;
      int df = dfs(e.to, min(flow, e.cap - e.flow));
      if (df) {
        e.flow += df;
        adj[e.to][e.rev].flow -= df;
        return df;
      }
    }
    return 0;
  }
  int maxFlow(int _s, int _t) {
    s = _s, t = _t;
    int totFlow = 0;
    while (bfs()) {
      int df = dfs(s, numeric_limits<int>::max());
      while (df) {
        totFlow += df;
        df = dfs(s, numeric_limits<int>::max());
      }
    }
    return totFlow;
  }
};
Dinic<71> Network;
bool do_the_good_stuff() {
  for (int i = 0; i < 71; i++) Network.adj[i].clear();
  int s = 0, t = 70;
  for (int i = 1; i <= 6; i++) {
    if (!f[i - 1]) continue;
    Network.addEdge(s, i, f[i - 1]);
    for (int mask = 1; mask < MX; mask++) {
      if (!cnt[mask]) continue;
      if ((mask >> (i - 1)) & 1)
        Network.addEdge(i, mask + 6, ITS_SO_FUCKING_BIG);
    }
  }
  for (int i = 7; i < t; i++)
    if (cnt[i - 6]) Network.addEdge(i, t, cnt[i - 6]);
  int flow = Network.maxFlow(s, t);
  return flow == req;
}
int main() {
  scanf("%s", s);
  n = strlen(s);
  req = n;
  int m;
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    int pos;
    char cur[6];
    scanf("%d", &pos);
    scanf("%s", cur);
    int len = strlen(cur);
    int mask = 0;
    for (int j = 0; j < len; j++) mask |= 1 << (cur[j] - 'a');
    maskat[pos] = mask;
    cnt[mask]++;
  }
  if (m == 0) {
    sort(s, s + n);
    return printf("%s", s), 0;
  }
  for (int i = 1; i <= n; i++) {
    if (!maskat[i]) {
      maskat[i] = MX - 1;
      cnt[maskat[i]]++;
    }
    f[s[i - 1] - 'a']++;
  }
  if (!do_the_good_stuff()) return cout << "Impossible", 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 6; j++) {
      if (((maskat[i] >> j) & 1) && f[j]) {
        if (!(maskat[i] >> (j + 1))) {
          f[j]--;
          cnt[maskat[i]]--;
          req--;
          printf("%c", char('a' + j));
          break;
        }
        f[j]--;
        cnt[maskat[i]]--;
        req--;
        if (do_the_good_stuff()) {
          printf("%c", char('a' + j));
          break;
        }
        f[j]++;
        cnt[maskat[i]]++;
        req++;
      }
    }
  }
  return 0;
}
