405155: GYM101807 G Go
Description
One day, GFRIEND members went to a Go club to perform their song and learn how to play Go.
[video]output.mp4[/video]
To teach them the basic rules of Go, the master gave them $$$N$$$ white stones and $$$M$$$ black stones. He then ask them to use the white stones to surround the black stones on the standard 19x19 Go board. The arrangement must satisfy the followings:
- They must use all $$$N$$$ white stones and all $$$M$$$ black stones.
- All black stones must be "captured". In order to capture a group of black stones, it must be surrounded by white stones in all 4 directions without gaps and spaces.
- Though it is not necessary for the black stones to form a single group, all white stones must be necessary, i.e. removing any one white stone will cause at least one black stone not being captured.
The above rules can also be expressed by the followings:
- The 19x19 board must contain exactly $$$N$$$ white stones and exactly $$$M$$$ black stones.
- Each white stone must be directly adjacent to (4 directions) at least 1 black stone.
- Each black stone must be directly adjacent to (4 directions) 4 black or white stones.
Help GFRIEND by writing a program to find out if there is a possible arrangement, and if there is, output any one.
InputThe input consists of 2 integers $$$N$$$ and $$$M$$$.
$$$1 \le N, M \le 80$$$.
OutputIf there is no possible arrangement that satisfies the rules, output Impossible.
Otherwise, output a 19x19 grid that contains any valid arrangement. Use . to represent empty space, o to represent white stone and x to represent black stone.
ExamplesInput20 25Output
...................Input
...................
...................
...................
...................
...................
...................
...................
...................
...................
..........ooooo....
.........oxxxxxo...
.........oxxxxxo...
.........oxxxxxo...
.........oxxxxxo...
.........oxxxxxo...
..........ooooo....
...................
...................
21 10Output
...................Input
...................
...................
...ooo.............
..oxxxo............
...ooxo............
.....o.............
.........o..o......
........oxooxo.....
........oxxxxo.....
.........oooo......
...................
...................
...................
...................
...................
...................
...................
...................
5 2Output
Impossible