Time limit
2s
Memory limit
128 MB
A text-mode screen contains several windows. Each window consists only of +, -, |, ., and a lowercase alphabetic title, and has the following form.
+--|abcdef|---+|.............||.............||.............||.............|+-------------+Every window follows this form. The width of each window is large enough to display its title. The title is placed exactly in the center of the top border; if the two side margins cannot be equal, the right margin is one character longer than the left margin.
You are given a screenshot. No two windows overlap. Rearrange all windows into a cascading layout according to the following rules and print the resulting screen.
The first line contains the screen height M and width N. (10 <= M, N <= 100) The next M lines each contain a string of length N, describing the current screenshot. The background is represented only by . characters. Every window title has length between 1 and 10 inclusive. You may assume that M and N are large enough to place all windows in the cascading layout.
Print M lines showing the screen after all windows have been rearranged into the cascading layout.
+--|abcdef|---+|.............||.............||.............||.............|+-------------+