// Arup Guha
// 1/26/2020
// Solution to 2020 January USACO Bronze Problem: Word Processor

import java.util.*;
import java.io.*;

public class word {
	
	public static void main(String[] args) throws Exception {
		
		Scanner stdin = new Scanner(new File("word.in"));
		PrintWriter out = new PrintWriter(new FileWriter("word.out"));
		
		// Read in words and width.
		int n = stdin.nextInt();
		int width = stdin.nextInt();
		String[] words = new String[n];
		for (int i=0; i<n; i++)
			words[i] = stdin.next();
			
		// Place all words.
		int idx = 0;
		while (idx < n) {
		
			// First in line is safe.
			out.print(words[idx]);
			int pos = words[idx].length();
			idx++;
			
			// Now see if we can add another!
			while (idx<n && pos+words[idx].length() <= width) {
				out.print(" "+words[idx]);
				pos += words[idx].length();
				idx++;
			}
			
			// Go to next line.
			out.println();
		}
		
		out.close();		
		stdin.close();
	}
}