Alphabetical Index#4060

Alphabetical Index

1 second
16 megabytes
Very hard

Documents created with word processors, unlike plain text files, include not only text but also various types of metadata. One such type of metadata is fields, which can describe inserted images, formulas, and control information. Fields containing control information are not visible when viewing the document in normal mode and are not considered during line and page breaks.

In a particular word processor, fields are described as follows:

Thus, the start of a field is marked by the symbol combination "{/". For example, a valid field description might look like this: {/AExample}.

One type of field is used for creating an alphabetical index. Let's assume that the code for such a field is the symbol "Z". The alphabetical index contains information about terms that appear in the document, along with the page numbers where these terms are found.

The alphabetical index is created from fields with the code "Z" according to the following rules:

Example of an alphabetical index:

AArbuz 12, 48Aspirin 34PSeller 73YApple 2

Consider a text consisting of words with inserted fields of different types (word boundaries are spaces, line beginnings, and line endings). It is assumed that a field is located on the same page as the nearest preceding word.

The task is to break the given text into lines and pages according to the following rules:

After formatting the text, construct the index.

Input

The first line contains two integers and , separated by a space — the maximum number of characters per line and the number of lines per page, respectively (10 \leq S \leq 100, 1 \leq N \leq 100).

The following lines contain the source text. The number of text lines is no more than . The length of a line is no more than . It is guaranteed that in the formatted text, there are no words longer than . It is guaranteed that there is at least one word before the first field. It is guaranteed that there is at least one field with the code "Z" in the text.

Output

The output file should contain the alphabetical index formed according to the rules specified above.

Examples

Example 1

Loading
Loading

Note

After breaking the source text into lines and pages, it will look like:

This is an example to 1 page

task

"Alphabetical 2 page

index", on

the basis of which 3 page

shows

the construction 4 page

of the alphabetical

index. 5 page