PROGRAMMING:six hundred and sixty-six

Xiao Ming has an M * n good habit record card to record the achievement of good habit goals every day (numbers 0-9). One day when the goal is achieved, write the number 6 in the grid of the day. If the goal is not fully achieved, write a number less than 6 (0-5). If the goal is over fulfilled, write a number greater than 6 (7-9). If you can find a path with a length of 3 on the record card, and the three numbers on the path are greater than or equal to 6 (the path here refers to starting from a certain grid, you can move to the left, right, upper and lower grids, and you can't repeatedly pass through a grid), Xiaoming will get a "666" reward< br>
Please help Xiao Ming count the total number of "666" awards he can get.
###Input format:
Enter the first line to give two positive integers m, n (1 = < m, n < = 100), followed by M lines, each containing N numbers between 0-9.
###Output format:
First output m lines, each line contains n integers, representing the number of "666" rewards from the current grid, with space in the middle, and no space after the last number. Then output the total number of "666" awards in the next line.
###Input example:
```in
3 3
6 6 7
3 8 3
7 9 5
```
###Output example:
```out
2 1 2
0 3 0
1 1 0
ten
```
answer:If there is no answer, please comment
Xiao Ming has an M * n good habit record card to record the achievement of good habit goals every day (numbers 0-9). One day when the goal is achieved, write the number 6 in the grid of the day. If the goal is not fully achieved, write a number less than 6 (0-5). If the goal is over fulfilled, write a number greater than 6 (7-9). If you can find a path with a length of 3 on the record card, and the three numbers on the path are greater than or equal to 6 (the path here refers to starting from a certain grid, you can move to the left, right, upper and lower grids, and you can't repeatedly pass through a grid), Xiaoming will get a "666" reward< br>
Please help Xiao Ming count the total number of "666" awards he can get.
###Input format:
Enter the first line to give two positive integers m, n (1 = < m, n < = 100), followed by M lines, each containing N numbers between 0-9.
###Output format:
First output m lines, each line contains n integers, representing the number of "666" rewards from the current grid, with space in the middle, and no space after the last number. Then output the total number of "666" awards in the next line.
###Input example:
```in
3 3
6 6 7
3 8 3
7 9 5
```
###Output example:
```out
2 1 2
0 3 0
1 1 0
ten
```
answer:If there is no answer, please comment