Pergunta de entrevista da empresa EarnIn

Fit a given sentence in certain row and column size matrix with some rules.