题目描述
Problem Description
The teacher has been researching Easy Language, a visual programming system under Windows, developed by Dalian Dayou Wutao Software Development Company, a system with Chinese intellectual property rights. To better learn this system, the teacher consciously applies it in practice to develop programs.
Today, the teacher encountered a problem: "When placing data on KOJ, the test data needs to be renamed accordingly." For example, if the original test data filenames are e0.in, e1.in ... e9.in and e0.out, e1.out ... e9.out, the teacher needs to rename all files to data1.in, data2.in ... data10.in and data1.out, data2.out ... data10.out. The program interface is shown below:
(Note: There seems to be a missing image here, but it does not affect the understanding of the problem)
Of course, the teacher is a novice in programming, far inferior to you, so his program is not very good. Now, he wants you to help improve this program.
Beforehand, the teacher will tell you the format of the target filenames. For example, if he tells you enger0.in and ans, it means the main name of the input file in the target files is enger, the extension is in, and the numbering starts from 0 and follows the main name. The output filenames will then be enger0.ans, enger1.ans ... engerX.ans, where X can be determined by counting the number of original filenames the teacher provides. Additionally, the teacher will also provide you with the full names of all original input data files, such as a1.txt, a2.txt ... aX.txt. However, the teacher is careless, and you should not expect the filenames he provides to be in ascending order by number, but they will be correct and follow the general rules of input and output filenames (the number will definitely appear at the end of the main name or the extension, and no other digits will appear elsewhere in the original or target filenames).
Some original input and output filenames do not need to change the main name and extension, only the file number. In this case, the teacher will first tell you a number 1 (or 0), indicating that the main name and extension of the final target files do not need to be changed, and only the numbering needs to be changed to start from 1 (or 0).
Input Format
The first line of input has two possible scenarios. The first scenario is two strings, representing the format of the final target filenames (the first one represents the name of the first input file in the target files). The second scenario is a single number 1 (or 0), indicating that the main name and extension of the filenames do not need to be changed, and only the numbering needs to be changed to start from 1 (or 0). The next n lines (1 ≤ n ≤ 10^5), each containing two strings separated by a space, represent the original input and output filenames (the main name and extension of all filenames in the input and output files do not exceed 10 characters, and the maximum number will not exceed 2 × 10^5).
Output Format
The output contains n lines, each with two strings separated by a space, representing the final target filenames. The first represents the input file, and the second represents the output file. Output them in ascending order by number.
Sample Input and Output
Sample Input #1
enger0.in ans
abc1.in abc1.out
abc2.in abc2.out
abc3.in abc3.out
abc4.in abc4.out
Sample Output #1
enger0.in enger0.ans
enger1.in enger1.ans
enger2.in enger2.ans
enger3.in enger3.ans
Sample Input #2
1
aa.in0 aa.ou0
aa.in1 aa.ou1
aa.in2 aa.ou2
Sample Output #2
aa.in1 aa.ou1
aa.in2 aa.ou2
aa.in3 aa.ou3
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分