eolymp
bolt
Try our new interface for solving problems
Problems

Hexagonal Pasture Network

Hexagonal Pasture Network

Farmer John recently acquired some new land to expand his farm. His cows have taken a liking to the hexagonal structure of bee honeycombs, and, ever willing to please his herd, Farmer John has set up a new system of pastures and cowpaths in this format.

The full plot of pastures and cowpaths forms a hexagon with side length k (2k50). Pastures are conveniently numbered 1..3 * k * (k - 1) + 1 starting in the bottom left and ending in the upper right using the pattern generalized from this illustration where k = 3:

prb8668.gif

Each pasture is connected to all of its immediate neighbors. This means that if a pasture is on the inside of the hexagon, it is adjacent to exactly six other pastures. For example, in the diagram above, pasture 10 is adjacent to pastures 5, 6, 11, 15, 14 and 9. Pastures on the edge (but not on a corner) of the structure are adjacent to exactly four other pastures (for example, pasture 4 is adjacent to 1, 5, 9 and 8) while pastures at a corner are adjacent to only three pastures (e.g., pasture 1 is connected to pastures 2, 5 and 4). The length of any cowpath connecting two pastures is 1 and the distance between two pastures is defined to be the length of the shortest possible route between them.

Farmer John's Holstein cows have been munching on the grass in pasture h (1h3 * k * (k - 1) + 1) for several days now and have grown fat and lazy. To force his cows to get some exercise, Farmer John has laid down tasty cow treats in pastures exactly distance of l (1l2 * k - 2) away from the cows. He guarantees the cows that he has placed at least one treat, but he doesn't tell the cows the pastures in which he's placed them.

Please help the cows avoid any unnecessary exercise by printing the number of possible pastures which might hold the treats and a list of those possible pastures in ascending order.

By way of example, suppose k = 3, the Holsteins are in pasture 1, and Farmer John says he's placed some treats in pastures a distance of 2 away. The possible locations of the treats are pastures 3, 6, 10, 9 and 8.

Input

One line contains three space-separated integers k, h and l.

Output

Print in the first line the number of pastures in a distance of l away from pasture h. In the next n lines print such pastures in ascending order.

Time limit 1 second
Memory limit 128 MiB
Input example #1
3 1 2
Output example #1
5
3
6
8
9
10
Source 2011 USACO Bronze Division, Февраль