Mine Layer is a puzzle much like Minesweeper. The board is an R×C grid, and every square either holds one mine or holds none.
The puzzle is given as a grid of numbers. Each number counts the mines in that square itself together with the squares next to it in all eight directions. Squares outside the board are not counted, so the numbers run from 0 to 9.
The goal is to find a mine layout that matches every given number.
The picture below shows a 3×4 grid. The original layout is on the left, and the puzzle built from it is on the right.

A puzzle can have several layouts, so print the largest number of mines the middle row can hold. The number of rows R is always odd, so the middle row is row (R+1)/2 counted from the top, and at least one layout always matches the numbers.