#P1953. 易语言

易语言

Description

Recently, the teacher has been studying Yi Language, a visual programming system for Windows, developed by Dalian Dayou Wutao Software Development Company, and possessing Chinese intellectual property rights. To learn this system better, the teacher deliberately uses it in practice to develop programs.

Today, the teacher encountered a problem: “When uploading testdata to KOJ, the testdata need to be renamed to the corresponding filenames.” For example, if the original testdata filenames are e0.in,e1.in  ...  e9.in\text{e0.in,\,e1.in\;...\;e9.in} and e0.out,e1.out  ...  e9.out\text{e0.out,\,e1.out\;...\;e9.out}, then the teacher needs to rename all files to data1.in,data2.in  ...  data10.in\text{data1.in,\,data2.in\;...\;data10.in} and data1.out,data2.out  ...  data10.out\text{data1.out,\,data2.out\;...\;data10.out}. The program interface is shown in the figure below:

(Note: An image seems to be missing here, but it does not affect understanding of the problem.)

Of course, the teacher is a novice at programming and is far less skilled than you, so the program is not good. Now the teacher would like you to help improve it.

In advance, the teacher will tell you the target filename format to be generated. For example, if the teacher tells you enger0.in\text{enger0.in} and ans\text{ans}, it means the basename of the input files in the target set is enger\text{enger}, the extension is in\text{in}, and the index starts from 00 and follows the basename. Naturally, the output filenames will be $\text{enger0.ans,\,enger1.ans\;...\;enger}x\text{.ans}$, where xx can be determined by counting how many original filenames the teacher provides. In addition, the teacher will also tell you the full names of all original input files, such as a1.txt,a2.txt  ...  ax.txt\text{a1.txt,\,a2.txt\;...\;a}x\text{.txt}. However, the teacher is careless. Do not expect the filenames to be given in ascending order of their indices, but the provided filenames are guaranteed to be correct and to follow general input/output filename conventions (the index number definitely appears at the end of the basename or at the end of the extension, and aside from this index number, no other digits will appear anywhere in either the original filenames or the target filenames).

Some original input/output filenames do not need changes to the basename or extension; only the file index needs to be changed. In this case, the teacher will first tell you a number 11 (or 00), meaning the basename and extension of the final target files should not be changed, and only the indices should be renumbered to start from 11 (or 00).

Input Format

The first line of input has two possibilities:

  • Two strings, which specify the format of the final target filenames (the first string is the name of the first input file in the generated target set).
  • A single number 11 (or 00), meaning the basename and extension do not need to change, and filenames only need to be renumbered starting from 11 (or 00).

Then follow nn lines (1n1051 \le n \le 10^5). Each line contains two strings separated by a single space, representing the original input and output filenames, respectively. For all input and output filenames, the basename and extension are each at most 1010 characters, and the maximum file index does not exceed 2×1052 \times 10^5.

Output Format

Output nn lines. Each line contains two strings separated by a single space, representing the final target filenames: the first is the input filename, and the second is the output filename. Output in ascending order of index.

enger0.in ans
abc1.in abc1.out
abc2.in abc2.out
abc3.in abc3.out
abc4.in abc4.out

enger0.in enger0.ans
enger1.in enger1.ans
enger2.in enger2.ans
enger3.in enger3.ans

1
aa.in0 aa.ou0
aa.in1 aa.ou1
aa.in2 aa.ou2

aa.in1 aa.ou1
aa.in2 aa.ou2
aa.in3 aa.ou3

Hint

Translated by ChatGPT 5