문제
Bessie is using the latest and greatest innovation in text-editing software, miV! Its powerful find-and-replace feature allows her to find all occurrences of a lowercase English letter and replace each with a nonempty string of lowercase letters . For example, given the string "", if Bessie selects to be 'l' and to be "", the given string transforms into "".
Bessie starts with the string "" and transforms it using a number of these find-and-replace operations, resulting in a final string . Since could be massive, she wants to know, given and with , what (the substring of from the -th to the -th character inclusive) is.
It is guaranteed that the sum of over all operations is at most , and that .
입력
The first line contains , , and the number of operations.
Each subsequent line describes one operation and contains and for that operation. All characters are in the range 'a' through 'z'.
출력
Output the string on a single line.
예제 입력 1
3 8 4
a ab
a bc
c de
b bbb
예제 출력 1
bdebbb
점수
Inputs 2-7: Inputs 8-15: No additional constraints.
코드를 제출하려면 로그인이 필요합니다.
로그인