Crahc with a String
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
Description
Crahc gives you a string consisting and . Denote the length of as .
You need to convert into the decimal representation of . For example, convert the string into .
Each conversion step involves two strings , where is not a substring of (also, is not empty). Note that both and can only consist of lowercase letters or digits. The single conversion step is defined as follows:
- Find the first occurrence of in .
- Replace the first occurrence of with .
- Repeat the above steps until no more occurrences of can be found in .
Crahc is impatient, so you can only perform up to steps. At any time (including when performing one step), the length of should not exceed .
Note that this problem does not require any input. You are only required to provide the steps for your conversion. Your solution must work for all valid strings.
Format
The first line contains a single integer , the number of conversion steps you will perform.
The next lines, each line contains two strings , separated by a comma, representing the conversion step from to .
Samples
The example is for illustration of the format only; it may be incorrect.
3
bb,
ac,2x
a2x,5
It works for .