Sometimes you may want to write a sentence into your nickname like "lubenwei niubi". But how to change it into a single word? Connect them one by one like "lubenweiniubi" looks stupid.
To generate a better nickname, Rikka designs a non-trivial algorithm to merge a string sequence s
1...s
n into a single string. The algorithm starts with s=s
1 and merges s
2...s
n into s one by one. The result of merging t into s is the shortest string r which satisfies s is a prefix of r and t is a subsequence of r.(If there are still multiple candidates, take the lexicographic order smallest one.)
String s is a prefix of r if and only if |s| ≤ |r| and for all index i ∈ [1, |s|], s
i = r
i.
String s is a subsequence of r if and only if there is an index sequence
)
which satisfies

.
For example, if we want to generate a nickname from "lubenwei niubi", we will merge "niubi" into "lubenwei", and the result is "lubenweiubi".
Now, given a sentence s
1...s
n with n words, Rikka wants you to calculate the resulting nickname generated by this algorithm.