#include <bits/stdc++.h>
using namespace std;
template <typename T>
string tostr(const T& t) {
  ostringstream os;
  os << t;
  return os.str();
}
long long big = 10000000;
int N;
vector<string> F;
string W;
char let;
bool equal(string& a, string& b) {
  if ((int)a.size() != (int)b.size()) return false;
  for (int i = (int)(0); i <= (int)((int)a.size() - 1); ++i) {
    if (toupper(a[i]) != toupper(b[i])) return false;
  }
  return true;
}
int getcnt(string& a) {
  int ret = 0;
  for (int i = (int)(0); i <= (int)((int)a.size() - 1); ++i) {
    ret += toupper(a[i]) == toupper(let);
  }
  return ret;
}
int main() {
  cin >> N;
  for (int i = (int)(0); i <= (int)(N - 1); ++i) {
    string s;
    cin >> s;
    F.push_back(s);
  }
  cin >> W;
  cin >> let;
  string ans = W;
  for (int i = (int)(0); i <= (int)((int)W.size() - 1); ++i) {
    string best = "";
    for (int j = (int)(0); j <= (int)((int)F.size() - 1); ++j) {
      string a = F[j];
      int len = (int)a.size();
      string b = W.substr(i, len);
      string cur = "";
      if (equal(a, b)) {
        for (int k = (int)(0); k <= (int)(len - 1); ++k) {
          if (toupper(W[i + k]) == toupper(let)) {
            for (int l = (int)('A'); l <= (int)('Z'); ++l) {
              if (toupper(W[i + k]) != l) {
                cur += (isupper(W[i + k]) ? l : tolower(l));
                break;
              }
            }
          } else
            cur += (isupper(W[i + k]) ? toupper(let) : tolower(let));
        }
        if (best == "")
          best = cur;
        else if (getcnt(cur) > getcnt(best))
          best = cur;
        else if (getcnt(cur) == getcnt(best) && cur < best)
          best = cur;
      }
    }
    for (int j = (int)(0); j <= (int)((int)best.size() - 1); ++j)
      ans[i + j] = best[j];
  }
  cout << ans << endl;
  return 0;
}
