Problem2381--NewFolder(1)

2381: NewFolder(1)

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 128 MB

Description

Time Limit: 2 sec / Memory Limit: 1024 MB

Score : 300300 points

Problem Statement

For two strings AA and BB, let A+BA+B denote the concatenation of AA and BB in this order.
You are given NN strings S_1,\ldots,S_NS1,,SN. Modify and print them as follows, in the order i=1, \ldots, Ni=1,,N:
  • if none of S_1,\ldots,S_{i-1}S1,,Si1 is equal to S_iSi, print S_iSi;
  • if XX (X>0)(X>0) of S_1,\ldots,S_{i-1}S1,,Si1 are equal to S_iSi, print S_i+Si+ ( +X++X+ ), treating XX as a string.

Constraints

  • 1 \leq N \leq 2\times 10^51N2×105
  • S_iSi is a string of length between 11 and 1010 (inclusive) consisting of lowercase English letters.

Input

Input is given from Standard Input in the following format:
NNS_1S1S_2S2\vdotsS_NSN

Output

Print NN lines as specified in the Problem Statement.


Sample Input Copy

5
newfile
newfile
newfolder
newfile
newfolder

Sample Output Copy

newfile
newfile(1)
newfolder
newfile(2)
newfolder(1)

Source/Category