what is the way to the solution?

I tried the following:

For every recognized language find the minimum and the maximum possible lines.

Then find the maximum and minimum possible lines for all.

For minimum to maximum test if it divides N.

This solves the first four tests.

Is this the right way?

Re: what is the way to the solution?

Try to form k languages (or k groups) where k is divider of N. Mine is N^2 solution.

Re: what is the way to the solution?

I go through the divisors of the number N and check if the array can be split into I phrases by the condition

Sorry for my English