402808: GYM100886 C Black and White Board
Description
You are given a chessboard of size n × m. The cells are painted black and white such that the cell (1, 1) is white, and any two adjacent cells have different color. Some cells of the chessboard are banned.
Your task is to find a connected figure on the chessboard which does not contain banned cells and contains exactly w white cells and b black cells. Two cells are adjacent if they share a side.
InputThe first line contains three integers n, m and k (1 ≤ n, m ≤ 10, 0 ≤ k ≤ n·m): the number of rows of the chessboard, the number of columns of the chessboard and the number of banned cells.
The following k lines contain the coordinates of banned cells. Each of these lines contains a pair of integers xi and yi (1 ≤ xi ≤ n, 1 ≤ yi ≤ m): the coordinates of a banned cell. All banned cells are distinct.
The last line contains two integers w and b (0 ≤ w, b ≤ n·m, w + b > 0).
OutputIf it is impossible to find a connected figure without banned cells with w white cells and b black cells, print a single line containing ":-(" without quotes.
Otherwise, print n lines containing m characters each which describe the figure. The lines must consist of characters "O", "X" and ".":
- character "O" means a white cell which is included in the desired figure,
- character "X" means a black cell which is included in the desired figure,
- character "." means a cell which is not included in the desired figure.
3 4 2Output
2 2
2 3
3 3
....Input
X..O
OXOX
8 10 1Output
1 5
19 9
..........
..X...XOX.
..O...O...
..XO.OXO..
..O.O.O.O.
.OXOXOXOXO
..O.O.O.O.
..........