CF95A.Hockey

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Petya loves hockey very much. One day, as he was watching a hockey match, he fell asleep. Petya dreamt of being appointed to change a hockey team's name. Thus, Petya was given the original team name ww and the collection of forbidden substrings s1,s2,...,sns_{1},s_{2},...,s_{n} . All those strings consist of uppercase and lowercase Latin letters. String ww has the length of w|w| , its characters are numbered from 11 to w|w| .

First Petya should find all the occurrences of forbidden substrings in the ww string. During the search of substrings the case of letter shouldn't be taken into consideration. That is, strings "aBC" and "ABc" are considered equal.

After that Petya should perform the replacement of all letters covered by the occurrences. More formally: a letter in the position ii should be replaced by any other one if for position ii in string ww there exist pair of indices l,rl,r ( 1<=l<=i<=r<=w1<=l<=i<=r<=|w| ) such that substring w[l ... r]w[l ... r] is contained in the collection s1,s2,...,sns_{1},s_{2},...,s_{n} , when using case insensitive comparison. During the replacement the letter's case should remain the same. Petya is not allowed to replace the letters that aren't covered by any forbidden substring.

Letter letterletter (uppercase or lowercase) is considered lucky for the hockey players. That's why Petya should perform the changes so that the letterletter occurred in the resulting string as many times as possible. Help Petya to find such resulting string. If there are several such strings, find the one that comes first lexicographically.

Note that the process of replacements is not repeated, it occurs only once. That is, if after Petya's replacements the string started to contain new occurrences of bad substrings, Petya pays no attention to them.

输入格式

The first line contains the only integer nn ( 1<=n<=1001<=n<=100 ) — the number of forbidden substrings in the collection. Next nn lines contain these substrings. The next line contains string ww . All those n+1n+1 lines are non-empty strings consisting of uppercase and lowercase Latin letters whose length does not exceed 100100 . The last line contains a lowercase letter letterletter .

输出格式

Output the only line — Petya's resulting string with the maximum number of letters letterletter . If there are several answers then output the one that comes first lexicographically.

The lexicographical comparison is performed by the standard < operator in modern programming languages. The line aa is lexicographically smaller than the line bb , if aa is a prefix of bb , or there exists such an ii ( 1<=i<=a1<=i<=|a| ), that a_{i}<b_{i} , and for any jj ( 1<=j<i ) aj=bja_{j}=b_{j} . a|a| stands for the length of string aa .

输入输出样例

  • 输入#1

    3
    bers
    ucky
    elu
    PetrLoveLuckyNumbers
    t
    

    输出#1

    PetrLovtTttttNumtttt
    
  • 输入#2

    4
    hello
    party
    abefglghjdhfgj
    IVan
    petrsmatchwin
    a
    

    输出#2

    petrsmatchwin
    
  • 输入#3

    2
    aCa
    cba
    abAcaba
    c
    

    输出#3

    abCacba
    
首页