#include <bits/stdc++.h>
using namespace std;
void _add(int &a, int b) { a = (a + b) % 1000000007; }
void _sub(int &a, int b) { a = (a + 1000000007 - b) % 1000000007; }
void _mul(int &a, int b) { a = (long long)a * b % 1000000007; }
void _max(int &a, int b) { a = max(a, b); }
void _min(int &a, int b) { a = min(a, b); }
long long gcd(long long a, long long b) {
  if (!b) return a;
  return gcd(b, a % b);
}
long long pw(long long a, long long b) {
  long long res(1);
  while (b) {
    if (b & 1) res = res * a % 1000000007;
    a = a * a % 1000000007;
    b >>= 1;
  }
  return res;
}
long long pwM(long long a, long long b, long long mod) {
  long long res(1);
  while (b) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return res;
}
const int infi = 2147483647;
const long long infl = 9223372036854775807ll;
const double PI = 3.14159265358979323846;
struct E {
  int v, f, F, n;
} G[1024];
int point[100], D[100], cnt, S, T;
void Ginit() {
  cnt = 1;
  memset(point, 0, sizeof point);
}
void adde(int u, int v, int f, int F = 0) {
  G[++cnt] = (E){v, 0, f, point[u]}, point[u] = cnt;
  G[++cnt] = (E){u, 0, F, point[v]}, point[v] = cnt;
}
int BFS() {
  queue<int> q;
  memset(D, 0, sizeof D);
  q.push(S);
  D[S] = 1;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = point[u]; i; i = G[i].n)
      if (G[i].F > G[i].f) {
        int v = G[i].v;
        if (!D[v]) {
          D[v] = D[u] + 1;
          if (v == T) return D[T];
          q.push(v);
        }
      }
  }
  return D[T];
}
int Dinic(int u, int F) {
  if (u == T) return F;
  int f = 0;
  for (int i = point[u]; i; i = G[i].n) {
    if (F <= f) break;
    int v = G[i].v;
    if (G[i].F > G[i].f && D[v] == D[u] + 1) {
      int temp = Dinic(v, min(F - f, G[i].F - G[i].f));
      if (temp == 0)
        D[v] = 0;
      else {
        f += temp;
        G[i].f += temp;
        G[i ^ 1].f -= temp;
      }
    }
  }
  if (!f) D[u] = 0;
  return f;
}
int maxflow() {
  int f = 0;
  while (BFS()) f += Dinic(S, infi);
  return f;
}
int n, m;
char s[100010], t[10], ans[100010];
int c[64], store[6], mask[100010];
bool check() {
  Ginit();
  S = 0, T = 6 + 64 + 1;
  int sum = 0;
  for (int i = 1, lim = 6; i <= lim; ++i) {
    adde(S, i, store[i - 1]);
    sum += store[i - 1];
    for (int j = 6 + 1, lim = 6 + 64; j <= lim; ++j)
      if ((j - 6 - 1) & (1 << (i - 1))) {
        adde(i, j, infi);
      }
  }
  for (int j = 6 + 1, lim = 6 + 64; j <= lim; ++j) {
    adde(j, T, c[j - 6 - 1]);
  }
  return maxflow() == n;
}
bool check1() {
  for (int i = 0, lim = 63; i <= lim; ++i) {
    int s = 0;
    for (int j = 0, lim = 5; j <= lim; ++j)
      if (i & (1 << j)) s += store[j];
    for (int j = 0, lim = 63; j <= lim; ++j)
      if (i & j) s -= c[j];
    if (s > 0) return 0;
  }
  return 1;
}
int main() {
  scanf("%s", s);
  n = strlen(s);
  for (int i = 0, lim = n - 1; i <= lim; ++i) store[s[i] - 'a']++;
  scanf("%d", &m);
  for (int i = 1, lim = m; i <= lim; ++i) {
    int k;
    scanf("%d", &k);
    k--;
    scanf("%s", t);
    for (int j = 0, lim = strlen(t) - 1; j <= lim; ++j)
      mask[k] |= 1 << (t[j] - 'a');
    if (!mask[k]) mask[k] = 63;
    c[mask[k]]++;
  }
  for (int i = 0, lim = n - 1; i <= lim; ++i)
    if (!mask[i]) c[mask[i] = 63]++;
  for (int i = 0, lim = n - 1; i <= lim; ++i) {
    c[mask[i]]--;
    int ok = 0;
    for (int k = 0, lim = 5; k <= lim; ++k)
      if (store[k] && (mask[i] & (1 << k))) {
        store[k]--;
        if (check1()) {
          ok = 1;
          ans[i] = k + 'a';
          break;
        }
        store[k]++;
      }
    if (!ok) {
      puts("Impossible");
      return 0;
    }
  }
  printf("%s", ans);
  return 0;
}
