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 w and the collection of forbidden substrings s1,s2,...,sn . All those strings consist of uppercase and lowercase Latin letters. String w has the length of ∣w∣ , its characters are numbered from 1 to ∣w∣ .
First Petya should find all the occurrences of forbidden substrings in the w 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 i should be replaced by any other one if for position i in string w there exist pair of indices l,r ( 1<=l<=i<=r<=∣w∣ ) such that substring w[l ... r] is contained in the collection s1,s2,...,sn , 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 letter (uppercase or lowercase) is considered lucky for the hockey players. That's why Petya should perform the changes so that the letter 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 n ( 1<=n<=100 ) — the number of forbidden substrings in the collection. Next n lines contain these substrings. The next line contains string w . All those n+1 lines are non-empty strings consisting of uppercase and lowercase Latin letters whose length does not exceed 100 . The last line contains a lowercase letter letter .
输出格式
Output the only line — Petya's resulting string with the maximum number of letters letter . 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 a is lexicographically smaller than the line b , if a is a prefix of b , or there exists such an i ( 1<=i<=∣a∣ ), that a_{i}<b_{i} , and for any j ( 1<=j<i ) aj=bj . ∣a∣ stands for the length of string a .
输入输出样例
输入#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