#!/usr/bin/env python3
import itertools

n, W = map(int, input().split())
words = [input() for _ in range(n)]


def test(m):
    dp = [100000000] * (n + 1)
    dp[0] = -1
    ws, js = [0] * (n + 1), [0] * (n + 1)
    for i in range(1, n + 1):
        w = 0
        for j in range(1, min(m, i) + 1):
            w = max(w, len(words[i - j]))
            d = dp[i - j] + w + 1
            if d < dp[i]:
                dp[i] = d
                ws[i] = w
                js[i] = j
    if dp[-1] > W:
        return False
    jss, wss, i = [], [], n
    while i > 0:
        jss.append(js[i])
        wss.append(ws[i])
        i -= js[i]
    return (dp, list(reversed(wss)), list(reversed(jss)))


l = 1
h = n
while l < h:
    m = (l + h) // 2
    if test(m):
        h = m
    else:
        l = m + 1

dp, ws, js = test(l)
r, c = l, len(ws)
print(r, c)
print(*ws)
ajs = list(itertools.accumulate([0] + js))
for i in range(r):
    for j in range(c):
        print(f"{words[ajs[j] + i] if i < js[j] else '':<{ws[j]}}", end=" ")
    print()
