Landmine Cleaner

In this problem, you are in a Landmine Cleaner (LC) team. Landmine Cleaner’s job is to identify and dispose of all landmines in a field so that troops can safely march through the field. Obviously, this is an extremely dangerous job! The first step in the process of landmine disposal is to identify where they are. Luckily, you have a Landmine Detector Drone (LDD) to help you locate the mines. LDD works by flying over a suspected area and send out a Z-ray, which is a military classified ray. If there is a mine below, the Z-ray will reflect from the mine and the LDD will pickup a strong signal. LDD however, is not perfect, because nearby mines can also reflect Z-ray and cause LDD to pick-up some amount of signal, albeit weaker. Your job in this problem is to determine where the mines are using the information from LDD signals. Remember, your fellow teammates’ life depend critically on the correctness of your solution! ThefieldinthisproblemisanN (1≤N ≤1,000)rowsbyM (1≤M ≤1,000)columnsgridof cells. A cell can either have 1 or 0 mine at the center. You are given the signal reading from LDD when it flies over the center of each cell. Consider 3 × 3 cells whose center cell is where your LDD is at. The LDD signal reading at the center cell will be equal to: If the center cell has landmine, 3 + number of landmines in the 3x3 cells If the center cell does not have landmine, 0 + number of landmines in the 3x3 cells In the following examples, ‘L’ indicates that there is a landmine in that cell, while ‘-’ indicates that there is no landmine in that cell. Your task in this problem is to determine for each cell if there is a landmine or not. Note: You can safely assume that there is no landmine outside the field. You can also be sure that the solution is unique. Input There are T test cases. The first line contains the number T (1 ≤ T ≤ 10). Then, T test cases follow, each using the following format. • The first line consists of two integers N and M. • Each of the next N line has M integers specify the LDD signal reading at each cell, each row per line, starting from the first row to the last row. In each line, there are M integers which indicate the reading of the specific row, starting from the first column to the last column. Output For each test case, you have to output N lines, each line is a length M string of ‘-’ and ‘L’ indicating whether there is a landmine or not.

2/2 Sample Input 1 34 2632 7575 6732 Sample Output -L-- L-LL LL--