#include <bits/stdc++.h>
using namespace std;
int const N = 80;
char ins[N + 1];
int I;
set<string> sp;
string an;
struct S {
  string s;
  bool sp;
  S(string const &a, bool b) : s(a), sp(b) {}
};
vector<S> in;
bool dg(char c) { return c >= '0' && c <= '9'; }
bool dg(string const &s) {
  for (int i = 0; i < (int)(s.size()); ++i)
    if (!dg(s[i])) return false;
  return true;
}
bool safeC(char c) {
  if (c >= 'a' && c <= 'z') return true;
  if (c >= 'A' && c <= 'Z') return true;
  if (c >= '0' && c <= '9') return true;
  return c == '_' || c == '$';
}
bool safe(string const &s) {
  for (int i = 0; i < (int)(s.size()); ++i)
    if (!safeC(s[i])) return false;
  if (dg(s[0])) {
    for (int i = 1; i < (int)(s.size()); ++i)
      if (!dg(s[i])) return false;
    return true;
  }
  return true;
}
bool issp(string const &s) { return sp.find(s) != sp.end(); }
string read() {
  while (ins[I] == ' ') ++I;
  string an;
  while (ins[I] != ' ' && ins[I]) an += ins[I++];
  return an;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < (int)(n); ++i) {
    scanf("%s", ins);
    sp.insert(ins);
  }
  scanf("%d\n", &n);
  for (int i = 0; i < (int)(n); ++i) {
    gets(ins);
    I = 0;
    string t;
    while (!(t = read()).empty()) {
      for (int i = 0; i < (int)(t.size()); ++i)
        if (t[i] == '#') {
          t.resize(i);
          ins[I] = 0;
        }
      while (!t.empty()) {
        string z = t;
        while (true) {
          if (issp(z)) {
            in.emplace_back(z, true);
            break;
          } else if (safe(z)) {
            in.emplace_back(z, false);
            break;
          }
          z.pop_back();
        }
        t = t.substr(z.size());
      }
    }
  }
  vector<string> ss;
  for (int a = 'a'; a < (int)('z' + 1); ++a)
    if (!issp(string() + (char)a)) ss.emplace_back(string() + (char)a);
  for (int a = 'a'; a < (int)('z' + 1); ++a)
    for (int b = 'a'; b < (int)('z' + 1); ++b)
      if (!issp(string() + (char)a + (char)b))
        ss.emplace_back(string() + (char)a + (char)b);
  for (int a = 'a'; a < (int)('z' + 1); ++a)
    for (int b = 'a'; b < (int)('z' + 1); ++b)
      for (int c = 'a'; c < (int)('z' + 1); ++c)
        if (!issp(string() + (char)a + (char)b + (char)c))
          ss.emplace_back(string() + (char)a + (char)b + (char)c);
  int ID = 0;
  map<string, int> mp;
  for (int i = 0; i < (int)(in.size()); ++i)
    if (!in[i].sp && !dg(in[i].s)) {
      auto it = mp.find(in[i].s);
      if (it == mp.end()) {
        mp[in[i].s] = ID;
        in[i].s = ss[ID++];
      } else
        in[i].s = ss[it->second];
    }
  vector<S> st;
  for (auto &s : in) {
    string sad = s.s;
    bool sp = false;
    for (int i = st.size() - 1; i >= 0; --i) {
      if (i + 1 == (int)st.size() && safeC(s.s[0]) && safe(st[i].s) &&
          (dg(s.s[0]) || !dg(st[i].s))) {
        sp = true;
        break;
      }
      sad = st[i].s + sad;
      if (sad.size() > 20) break;
      for (int i = 1; i < (int)(s.s.size() + 1); ++i)
        if (issp(sad.substr(0, sad.size() - s.s.size() + i))) {
          sp = true;
          break;
        }
    }
    if (sp) {
      an += ' ';
      st.clear();
    }
    an += s.s;
    st.emplace_back(s);
  }
  printf("%s\n", an.c_str());
}
