Diti's friends are visiting her house for her birthday. The party has N x M members including Diti. Diti's father has organized the party and he wants everyone to return satisfied. A member will be satisfied only if he/she has a piece of chocolate.
Diti's father organized everyone into N rows with each row having M members. Diti's father may initially give chocolates to any number of members. Consider every chocolate to be sufficiently large such that it can be shared with many people. If at any point of time, a person who has a piece of chocolate sees that his neighbour also has a piece of chocolate, he feels sorry for all his other neighbours who don't have a piece of chocolate and shares a part of his chocolate with all of them.
Given the initial distribution of chocolates, report whether everyone will get a piece of chocolate or not, also report the minimum number of chocolates that should be added in the initial configuration such that every child gets at least one piece of it.
Note: Two cells are neighbours if they share a common edge.