Ondra, Matěj, and Kuba are returning from gathering nuts, and they have a total of 120. Matěj complains that Ondra, as always, has the most. Their father orders Ondra to give Matěj enough nuts to double his amount. Now Kuba complains that Matěj has the most. On their father's command, Matěj gives Kuba enough nuts to double his amount. Then Ondra gets upset, saying he has the least now. Kuba thus gives Ondra enough nuts to double his amount. Now they all have the same amount, and finally, there is peace.

How many nuts did each of the boys originally have?

(M. Volfová)

Hint. What was the distribution of nuts before they all had the same?