#include <bits/stdc++.h>
using namespace std;
class Solution {
 public:
  Solution(int A = 6) : an(A), N(1 << A) {}
  string rename(string& s, vector<pair<int, string>>& rs) {
    int n = s.length();
    vector<int> cnts(N, 0);
    for (auto c : s) {
      ++cnts[c - 'a'];
    }
    vector<int> allowed(n, N - 1);
    for (auto& p : rs) {
      int j = p.first;
      auto& t = p.second;
      allowed[j] = 0;
      for (auto c : t) {
        allowed[j] |= 1 << (c - 'a');
      }
    }
    vector<int> left(N, 0);
    vector<int> matching(N, 0);
    for (int mask = 0; mask < N; ++mask) {
      for (int i = 0, f = 1; i < an; ++i, f <<= 1) {
        if (mask & f) {
          left[mask] += cnts[i];
        }
      }
    }
    for (int i = 0; i < n; ++i) {
      for (int mask = 0; mask < N; ++mask) {
        if (mask & allowed[i]) {
          ++matching[mask];
        }
      }
    }
    for (int mask = 0; mask < N; ++mask) {
      if (matching[mask] < left[mask]) {
        return "";
      }
    }
    string res;
    for (int i = 0; i < n; ++i) {
      int poss = allowed[i];
      for (int mask = 0; mask < N; ++mask) {
        if ((mask & allowed[i]) && left[mask] == matching[mask]) {
          poss &= mask;
        }
      }
      for (int j = 0; j < an; ++j) {
        if ((1 << j) & poss) {
          res += 'a' + j;
          for (int mask = 0; mask < N; ++mask) {
            if (mask & allowed[i]) {
              --matching[mask];
            }
            if (mask & (1 << j)) {
              --left[mask];
            }
          }
          break;
        }
      }
    }
    return res;
  }

 private:
  int an;
  int N;
};
int main(int argc, char** argv) {
  string s;
  cin >> s;
  int m;
  cin >> m;
  vector<pair<int, string>> requests;
  requests.reserve(m);
  for (int i = 0; i < m; ++i) {
    int p;
    string t;
    cin >> p >> t;
    requests.emplace_back(p - 1, t);
  }
  Solution sol;
  auto res = sol.rename(s, requests);
  if (res.empty()) {
    cout << "Impossible" << endl;
  } else {
    cout << res << endl;
  }
  return 0;
}
