John, an entomologist (entomology is the study of insects), is studying the relationship between bees and beehives. He found that each bee has a home cell in a beehive. Furthermore, he observed that, for all bees of a particualar beehive, they visit other cells that are exactly n number of cells away from their home cell. The number n is unique for different beehives.
John wants to find out the number n of all his beehives. To do this, he puts a sensor in every cell of the beehives. Then he takes a number of bees from each beehive and tags each of them with a tiny transmitter. Each transmitter emits different signal so that all visits of the cells by any tagged bee are recorded by the sensors.
After a week he takes out all the sensors and is prepared to get the results. But he has problem doing the calcuation: he does not know how to find out the set of cells that are exactly m cells away from a certain cell. Now he needs your help to solve this problem.
For a particular beehive (assuming that each beehive is regular), the cells are represented in the following way: starting with 0 for the top-left cell, the cell number is increased by one as it goes to the next cell on the right; at the end of a row, the numbering continues with the leftmost cell of the next row (see Figure ). Therefore the numbering is different for different size of the beehive. The size of a beehive is determined by the number of cells along each side. For Figure , the left beehive has a size of 4, and the right beehive has a size is 5.
Figure: A size-4 beehive (left) and a size-5 beehive (right).