cho.sh
Notes
Loading...

Automatic Sprinklers

Time limit

1s

Memory limit

128 MB

Problem

A farm is divided into an 8 by 8 grid of unit plots. To control crop yield, automatic sprinklers can be installed on unit plots. A fertilizer sprinkler increases yield, and a herbicide sprinkler decreases yield. A sprinkler sprays every plot in its row and every plot in its column, including the plot where it is installed.

Before any sprinklers are installed, all unit plots have exactly the same yield. This value is called the base yield. Each fertilizer effect on a plot increases its yield by 1, and each herbicide effect on a plot decreases its yield by 1. For example, when the base yield is 30, installing one fertilizer sprinkler and one herbicide sprinkler can produce final yields like the following.

At most one automatic sprinkler may be installed on a unit plot. Therefore, a fertilizer sprinkler and a herbicide sprinkler cannot be placed on the same plot, and two or more sprinklers of the same kind cannot be placed on the same plot.

Given the final yields of an 8 by 8 farm whose base yield is M, determine the position and type of every automatic sprinkler.

Input

The first line contains the base yield M, where 30 ≤ M ≤ 40.

The second line contains the number K of automatic sprinklers installed on the farm, where 1 ≤ K ≤ 63.

The next 8 lines describe the final yields of the 8 by 8 farm from top to bottom. Each line contains 8 positive integers separated by spaces, giving the yields of the plots in that row.

Output

Print 8 lines. In the same order as the input grid, print the automatic sprinkler information for each unit plot.

Print + for a fertilizer sprinkler, - for a herbicide sprinkler, and . for a plot without a sprinkler. Separate the 8 symbols in each row by single spaces.