Smoothing is used to reduce noise within an image or to produce a less pixelated image. You have been given an image G of resolution N x N. Image will be represented as a \(2D\) grid G of size N x N where \(G_{i, j}\) will denote intensity of color in a grayscale image of pixel \((i,\;j)\).
You have been given a filter mask F of size \((2 * M + 1)\) x \( (2 * M + 1)\). Using this filter mask, you have to perform smoothing operation on the G and output the final image \(NewG\). Smoothing operation for any particular pixel \((i, \;j)\) can be described as:
\(NewG_{i, j} = \sum_{p=-M}^{p=M} \sum_{q=-M}^{q=M} G_{i+p, j+q} * F_{p, q}\)
In the above formula, if any pixel \((x,\;y)\) is situated outside of grid of size N x N, then \(G_{x, y} = 0\).
INPUT:
First line of input will consists of two integers N and M. Next \(2 * M + 1\) lines will consists of \(2 * M + 1\) integers denoting filter mask F. \((M+1)^{th}\) integer on \((M+2)^{th}\) line will give the value of \(F_{0, 0}\), first integer on second line will give the value of \(F_{-M, -M}\) and last integer on \((2 * M + 2)^{th}\) line will give the value of \(F_{M, M}\).
Next N lines will consists of N integers denoting the image G.
OUTPUT:
Output the image \(NewG\) obtained by smoothing the image G using filter mask F.
CONSTRAINTS
\(2 \le N \le 100\)
\(1 \le M \le 10\)
\(0 \le G_{i,j}, F_{i,j} \le 100\)