#abc261c. [abc261_c]NewFolder(1)

[abc261_c]NewFolder(1)

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 S1,ldots,SNS_1,\\ldots,S_N. Modify and print them as follows, in the order i=1,ldots,Ni=1, \\ldots, N:

  • if none of S1,ldots,Si1S_1,\\ldots,S_{i-1} is equal to SiS_i, print SiS_i;
  • if XX (X>0)(X>0) of S1,ldots,Si1S_1,\\ldots,S_{i-1} are equal to SiS_i, print Si+S_i+ ( +X++X+ ), treating XX as a string.

Constraints

  • 1leqNleq2times1051 \\leq N \\leq 2\\times 10^5
  • SiS_i 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:

NN S1S_1 S2S_2 vdots\\vdots SNS_N

Output

Print NN lines as specified in the Problem Statement.


Sample Input 1

5
newfile
newfile
newfolder
newfile
newfolder

Sample Output 1

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

Sample Input 2

11
a
a
a
a
a
a
a
a
a
a
a

Sample Output 2

a
a(1)
a(2)
a(3)
a(4)
a(5)
a(6)
a(7)
a(8)
a(9)
a(10)