#include <bits/stdc++.h>
using namespace std;
vector<string> reserved_tokens;
bool is_reserved_token(const string& s) {
  for (auto t : reserved_tokens)
    if (t == s) return true;
  return false;
}
bool is_number(const string& s) {
  for (auto c : s)
    if (c < '0' || c > '9') return false;
  return true;
}
bool is_word(const string& s) {
  if (s[0] >= '0' && s[0] <= '9') return false;
  for (auto c : s)
    if ((c < 'a' || c > 'z') && (c < 'A' || c > 'Z') && (c < '0' || c > '9') &&
        c != '_' && c != '$')
      return false;
  return true;
}
bool is_valid_token(const string& s) {
  bool res = is_reserved_token(s) || is_number(s) || is_word(s);
  return res;
}
char buffer[100];
int main() {
  int N;
  scanf("%d", &N);
  for (int i = (int)(0); i < N; ++i) {
    scanf("%s", buffer);
    reserved_tokens.push_back(buffer);
  }
  int M;
  scanf("%d\n", &M);
  vector<string> tokens;
  for (int i = (int)(0); i < M; ++i) {
    string buffer;
    getline(cin, buffer);
    int L = buffer.size();
    for (int i = (int)(0); i < L; ++i)
      if (buffer[i] == '#') L = i;
    int s = 0;
    while (s < L) {
      if (buffer[s] == ' ') {
        ++s;
        continue;
      }
      int e = s;
      while (e < L && buffer[e] != ' ') ++e;
      while (s < e && !is_valid_token(string(buffer.c_str() + s, e - s))) --e;
      tokens.push_back(string(buffer.c_str() + s, e - s));
      s = e;
    }
  }
  int T = tokens.size();
  vector<bool> swapped(T, false);
  string new_token = "";
  for (int t = (int)(0); t < T; ++t) {
    if (is_reserved_token(tokens[t]) || is_number(tokens[t]) || swapped[t])
      continue;
    do {
      bool changed = false;
      for (int i = (int)(new_token.size()) - 1; i >= (0); --i) {
        if (new_token[i] == 'z')
          new_token[i] = 'a';
        else {
          new_token[i]++;
          changed = true;
          break;
        }
      }
      if (!changed) new_token = new_token + 'a';
    } while (is_reserved_token(new_token));
    for (int t1 = (int)(T)-1; t1 >= (t); --t1)
      if (tokens[t1] == tokens[t] && !swapped[t1]) {
        tokens[t1] = new_token;
        swapped[t1] = true;
      }
  }
  vector<string> output_tokens = {};
  for (int i = (int)(0); i < tokens.size(); ++i) {
    auto t = tokens[i];
    bool can_concat = output_tokens.size() > 0;
    if (!output_tokens.empty()) {
      int len = 0;
      string suf = "";
      for (int j = (int)(i)-1; j >= (0); --j) {
        if (suf.size() + tokens[j].size() > output_tokens.back().size()) break;
        suf = tokens[j] + suf;
        for (int k = (int)(0); k < t.size(); ++k) {
          if (is_valid_token(suf + t.substr(0, k + 1))) can_concat = false;
        }
      }
    }
    if (can_concat)
      output_tokens.back() += t;
    else
      output_tokens.push_back(t);
  }
  for (int i = (int)(0); i < output_tokens.size(); ++i) {
    if (i > 0) printf(" ");
    printf("%s", output_tokens[i].c_str());
  }
  printf("\n");
}
