#include <bits/stdc++.h>
using namespace std;
const int N = 300000;
int n;
set<string> keys_set;
vector<string> keys_vec;
char w[N];
bool is_word(char c) {
  return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
         (c >= '0' && c <= '9') || c == '_' || c == '$';
}
bool is_number(string& s) {
  for (int i = 0; i < int(s.length()); i++)
    if (!isdigit(s[i])) return false;
  return true;
}
bool is_word(string& s) {
  if (is_word(s[0]) && !isdigit(s[0])) {
    for (int i = 0; i < int(s.length()); i++)
      if (!is_word(s[i])) return false;
    return true;
  }
  return false;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < int(n); i++) {
    scanf("%s", w);
    keys_set.insert(w);
  }
  keys_vec = vector<string>(keys_set.begin(), keys_set.end());
  int m;
  scanf("%d\n", &m);
  vector<string> ss;
  string line;
  while (getline(cin, line)) {
    for (int i = 0; i < int(line.length()); i++)
      if (line[i] == '#') {
        line = line.substr(0, i);
        break;
      }
    stringstream xx;
    xx << line;
    while (xx >> line) ss.push_back(line);
  }
  vector<string> toks;
  for (int i = 0; i < int(ss.size()); i++) {
    string s = ss[i];
    int pos = 0;
    while (pos < s.length()) {
      int len = 0;
      if (isdigit(s[pos])) {
        int num_len = 0;
        int p = pos;
        while (isdigit(s[p])) p++, num_len++;
        len = max(len, num_len);
      }
      if (!isdigit(s[pos]) && is_word(s[pos])) {
        int word_len = 0;
        int p = pos;
        while (is_word(s[p])) p++, word_len++;
        len = max(len, word_len);
      }
      for (int j = 0; j < int(n); j++) {
        if (keys_vec[j].length() <= s.length() - pos) {
          bool ok = true;
          string key = keys_vec[j];
          for (int t = 0; t < int(key.length()); t++)
            if (key[t] != s[pos + t]) {
              ok = false;
              break;
            }
          if (ok) {
            len = max(len, int(key.length()));
          }
        }
      }
      assert(len > 0);
      toks.push_back(s.substr(pos, len));
      pos += len;
    }
  }
  vector<int> types(toks.size());
  for (int i = 0; i < int(toks.size()); i++) {
    if (is_number(toks[i]))
      types[i] = 1;
    else if (is_word(toks[i]))
      types[i] = 2;
  }
  vector<string> words;
  for (int i = 1; i <= 4; i++) {
    int size = 1;
    for (int j = 0; j < int(i); j++) size *= 26;
    for (int j = 0; j < int(size); j++) {
      string s;
      int jj = j;
      for (int pos = 0; pos < int(i); pos++) {
        s += char('a' + (jj % 26));
        jj /= 26;
      }
      reverse(s.begin(), s.end());
      words.push_back(s);
    }
  }
  map<string, string> comp;
  int ncomp = 0;
  for (int i = 0; i < int(toks.size()); i++) {
    if (types[i] == 2 && keys_set.count(toks[i]) == 0) {
      if (comp.count(toks[i]) == 0) {
        while (keys_set.count(words[ncomp]) != 0) {
          ncomp++;
        }
        comp[toks[i]] = words[ncomp++];
      }
      toks[i] = comp[toks[i]];
    }
  }
  int l = 0;
  string p;
  vector<int> starts(toks.size());
  string result;
  for (int i = 0; i < int(toks.size()); i++) {
    if (l == i) {
      p = toks[i];
      continue;
    }
    bool can = true;
    if (types[i - 1] == 1 && types[i] == 1) can = false;
    if (types[i - 1] == 2 && types[i] == 2) can = false;
    if (types[i - 1] == 2 && types[i] == 1) can = false;
    bool merge = false;
    if (can) {
      int plen = p.length();
      p += toks[i];
      int before = max(l, i - 300);
      merge = true;
      for (int j = before; j < i; j++) {
        int max_len = 0;
        for (int t = 0; t < int(n); t++)
          if (starts[j] + keys_vec[t].length() <= p.length()) {
            bool ok = true;
            for (int tt = 0; tt < int(keys_vec[t].length()); tt++)
              if (p[starts[j] + tt] != keys_vec[t][tt]) {
                ok = false;
                break;
              }
            if (ok) {
              max_len = max(max_len, int(keys_vec[t].length()));
            }
          }
        if (max_len > toks[j].length()) {
          merge = false;
        }
        if (types[j] == 1 && p.length() >= starts[j] + toks[j].length() + 1) {
          if (isdigit(p[starts[j] + toks[j].length()])) merge = false;
        }
        if (types[j] == 2 && p.length() >= starts[j] + toks[j].length() + 1) {
          if (is_word(p[starts[j] + toks[j].length()])) merge = false;
        }
      }
      p.resize(plen);
    }
    if (merge) {
      starts[i] = p.length();
      p += toks[i];
    } else {
      if (!p.empty()) {
        if (!result.empty()) result += " ";
        result += p;
      }
      p = toks[i];
      l = i;
    }
  }
  if (!p.empty()) {
    if (!result.empty()) result += " ";
    result += p;
  }
  cout << result << endl;
}
