Problem J
Watchdog
A company (name withheld) has an office building in the center of Lund. The building has a perfectly square roof with a number of hatches. Because of a series of burglaries where the perpetrators have entered through these hatches, it was decided to use a watchdog to guard the hatches. A particularly vicious but rather stupid breed of dog was chosen, and unfortunately the dog fell off the roof on its third watch.
A new dog has been procured and it has been decided to
attach a leash to its collar and attach the other end at some
point on the roof. However, if the leash is too short the dog
cannot reach all hatches, but if it is too long then the dog
will fall off the building again. The leash has hooks at both
ends, so no part of it is used to tie knots. The company wants
the dog to reach the center of each hatch (the dog can reach
exactly as far as the leash could reach if it were lying flat
on the roof), but it does not want the leash to extend beyond
the edge of the roof (to the edge is OK). They hope that by
carefully choosing the length of the leash and where to attach
it, the dog will be able to reach all hatches without risking
falling off the building. A leash can only be attached at a
point with integer coordinates (if the building is
If there is no place where you can attach a leash, reach all hatches but not reach beyond the edge of the roof, it is impossible to use this breed of dog, and the company will instead use a poodle (which is a less vicious type of dog, but also less prone to falling off buildings).
Input
On the first line of the input is a single positive integer
Output
For each test case, output one line containing the
coordinates
Sample Input 1 | Sample Output 1 |
---|---|
3 10 2 6 6 5 4 20 2 1 1 19 19 10 3 1 1 1 2 1 3 |
3 6 poodle 2 2 |