#include <iostream>
#include <cstring>
using namespace std;
const int MAX_LENGTH = 100;
char currentLine[MAX_LENGTH + 1][MAX_LENGTH + 1];
int wordsLength[MAX_LENGTH] = {0};
int charCounter(int counter) {
int chars = 0;
for (int i = 1; i <= counter; ++i) {
chars += strlen(currentLine[i]);
}
return chars;
}
void formatLine(int wordsPerLine, int columns) {
int spaces = wordsPerLine - 1, neededStars = columns - charCounter(wordsPerLine);
for (int i = 1; spaces != 0; ++i) {
int stars = neededStars / spaces;
if (neededStars % spaces) {
++stars;
}
char addStars[MAX_LENGTH + 1];
for (int j = 0; j < stars; ++j) {
addStars[j] = '*';
addStars[j + 1] = '\0';
}
--spaces;
neededStars -= stars;
cout << currentLine[i] << addStars;
}
cout << currentLine[wordsPerLine] << "\n";
}
int main() {
int noWords, lines, columns, wordsPerLine = 0, noLine = 0, charLine = 0;
cin >> noWords >> lines >> columns;
for (int i = 1; i <= noWords; ++i) {
char word[MAX_LENGTH + 1];
cin >> word;
int wordLength = strlen(word);
charLine += wordLength + 1;
if (columns + 1 >= charLine) {
strcpy(currentLine[++wordsPerLine], word);
} else {
++noLine;
formatLine(wordsPerLine, columns);
if (noLine % lines == 0) {
cout << "\n";
}
charLine = wordLength + 1;
strcpy(currentLine[1], word);
wordsPerLine = 1;
}
}
formatLine(wordsPerLine, columns);
return 0;
}