~/algor $ cat problems/string-qatorlarga-bolish
Split text into lines
Medium
1000 ms
64 MB
52%
The screen is $k$ characters wide. Split a text of words into lines: the words go in order, words on the same line are separated by single spaces, and no line is longer than $k$; if the next word does not fit, it starts a new line. Words are never broken (no word is longer than $k$). Print the resulting lines.
Input
The first line contains a positive integer $k$.
The second line contains the words separated by single spaces.
Output
The resulting lines.
Note
$1 \le k \le 1000$
the words consist of lowercase Latin letters, none longer than $k$
the length of the second line does not exceed $10^{5}$
Examples
Input #1
12 men har kuni algoritm masalalarini yechaman
Output #1
men har kuni algoritm masalalarini yechaman
Input #2
5 salom
Output #2
salom