B - Vertical Writing Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 200

問題文

横書きの文章が与えられます。縦書きに直してください。空白を * で埋めてください。

N 個の、英小文字からなる文字列 S_1,S_2,\dots,S_N が与えられます。これらの文字列の長さの最大値を M とします。

以下の条件を満たす M 個の文字列 T_1,T_2,\dots,T_M を出力してください。

  • T_i は英小文字および * からなる
  • T_i の末尾は * でない
  • 1 \leq i \leq N について、次が成り立つ
    • 1 \leq j \leq |S_i| について、T_jN-i+1 文字目が存在し、T_1,T_2,\dots,T_{|S_i|} それぞれの N-i+1 文字目をこの順に連結したものは S_i と一致する
    • |S_i| + 1 \leq j \leq M について、T_jN-i+1 文字目は存在しないか、 * である

ただし、|S_i| で文字列 S_i の長さを表します。

制約

  • N1 以上 100 以下の整数
  • S_i は長さ 1 以上 100 以下の英小文字からなる文字列

入力

入力は以下の形式で標準入力から与えられる。

N
S_1
S_2
\vdots
S_N

出力

答えを以下の形式で出力せよ。

T_1
T_2
\vdots
T_M

入力例 1

3
abc
de
fghi

出力例 1

fda
geb
h*c
i

T_32 文字目を * とすることで、 c が正しい位置に来ます。 T_42,3 文字目を * とした場合、T_4 の末尾が * となり、条件を満たしません。


入力例 2

3
atcoder
beginner
contest

出力例 2

cba
oet
ngc
tio
end
sne
ter
*r

Score : 200 points

Problem Statement

You are given a horizontally written text. Convert it to vertical writing, filling spaces with *.

You are given N strings S_1, S_2, \dots, S_N consisting of lowercase English letters. Let M be the maximum length of these strings.

Print M strings T_1, T_2, \dots, T_M that satisfy the following conditions:

  • Each T_i consists of lowercase English letters and *.
  • Each T_i does not end with *.
  • For each 1 \leq i \leq N, the following holds:
    • For each 1 \leq j \leq |S_i|, the (N-i+1)-th character of T_j exists, and the concatenation of the (N-i+1)-th characters of T_1, T_2, \dots, T_{|S_i|} in this order equals S_i.
    • For each |S_i| + 1 \leq j \leq M, the (N-i+1)-th character of T_j either does not exist or is *.

Here, |S_i| denotes the length of the string S_i.

Constraints

  • N is an integer between 1 and 100, inclusive.
  • Each S_i is a string of lowercase English letters with length between 1 and 100, inclusive.

Input

The input is given from Standard Input in the following format:

N
S_1
S_2
\vdots
S_N

Output

Print the answer in the following format:

T_1
T_2
\vdots
T_M

Sample Input 1

3
abc
de
fghi

Sample Output 1

fda
geb
h*c
i

Placing * as the 2nd character of T_3 puts the c in the correct position. On the other hand, placing * as the 2nd and 3rd characters of T_4 would make T_4 end with *, which violates the condition.


Sample Input 2

3
atcoder
beginner
contest

Sample Output 2

cba
oet
ngc
tio
end
sne
ter
*r