#ABC261C. [ABC261C] NewFolder(1)

[ABC261C] NewFolder(1)

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

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

Constraints

  • 1N2×1051 \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

SNS_N

Output

Print NN lines as specified in the Problem Statement.

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