#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
char A[N], L[N][10];
bool vis[N];
vector<int> Q[6][6];
int stk[10], cnt = 0;
bool M[6];
int tar[100], par[N];
void ff(int x) {
  int l = strlen(L[x]);
  for (int j = 0; j < l; j++) Q[L[x][j] - 'a'][A[x] - 'a'].push_back(x);
}
void Swap(int idx, int ins) {
  int tn = 0, op = idx;
  tar[tn++] = idx;
  while (par[op] != -1) op = tar[tn++] = par[op];
  int tt = tn;
  while (tt > 0) {
    int p = tar[--tt], ins1 = A[p] - 'a';
    A[p] = (char)(ins + 'a');
    ff(p);
    ins = ins1;
  }
}
bool f(int idx, int G) {
  memset(M, 0, sizeof(M));
  cnt = 0;
  stk[cnt++] = idx;
  if (G == (A[stk[0]] - 'a')) return true;
  M[(A[stk[0]] - 'a')] = true;
  par[idx] = -1;
  while (cnt > 0) {
    int p = stk[--cnt];
    int u = (A[p] - 'a');
    for (int j = 0; j < 6; j++) {
      vector<int>& q = Q[u][j];
      while (!q.empty()) {
        int g = q.back();
        if (vis[g] || (A[g] - 'a') != j)
          q.pop_back();
        else {
          if (!M[j]) {
            M[j] = true, stk[cnt++] = g, par[g] = p;
            if (G == j) {
              Swap(g, j);
              return true;
            }
          }
          break;
        }
      }
    }
  }
  return false;
}
int W[N], wn = 0;
int main() {
  int m;
  scanf("%s %d", A, &m);
  int la = strlen(A);
  for (int i = 0; i < m; i++) {
    int x;
    scanf("%d", &x);
    x--;
    scanf("%s", L[x]);
    ff(x);
    W[wn++] = x;
  }
  for (int i = 0; i < la; i++) {
    if (strlen(L[i]) == 0) {
      strcpy(L[i], "abcdef");
      ff(i);
    }
  }
  for (int k = 0; k < wn; k++) {
    int i = W[k];
    bool pass = false;
    for (int j = 0; j < strlen(L[i]); j++)
      if (f(i, L[i][j] - 'a')) {
        pass = true;
        break;
      }
    if (!pass) return cout << "Impossible\n", 0;
  }
  for (int i = 0; i < la; i++) {
    bool pass = false;
    vector<int> tmp;
    tmp.clear();
    for (int j = 0; j < strlen(L[i]); j++) tmp.push_back(L[i][j] - 'a');
    sort(tmp.begin(), tmp.end());
    for (int j = 0; j < strlen(L[i]); j++)
      if (f(i, tmp[j])) {
        pass = true;
        vis[i] = true;
        break;
      }
    if (!pass) return cout << "Impossible\n", 0;
  }
  cout << A << '\n';
}
