Long time ago, in the jungle there occurred a war between the owls and the birds on who were the best birds of jungle. After many days, owls began to lose and they surrendered. To spare their lives, all birds hired owls on an agreement. The agreement was that each owl will be assigned to a group of birds. He will collect the grains from all birds of its group and divide them equally among all. If some grains were left, then owl can take it as his fee. Since they are not good at maths, help the owl in the division of grains.