Dhoni has a field divided into n×mn\times mn×m squares of the same area. The amount of rice at each square will be given. He wants to divide his field into three parts containing AAA, BBB*,* and CCC tons of rice. The field should be divided by two parallel lines. The lines should be parallel to one side of the field. The lines should not intersect any square. Each resulting part of the field should consist of at least one square.

This is a companion discussion topic for the original entry at https://toph.co/p/division