A colony lives on an R by C grid. Each cell is either alive (1) or dead (0). Advance the colony by exactly one generation using these standard rules, where a cell's neighbours are the up to eight cells orthogonally or diagonally adjacent (no wrap-around):
- A live cell with fewer than 2 live neighbours dies; with 2 or 3 live neighbours it stays alive; with more than 3 it dies.
- A dead cell with exactly 3 live neighbours becomes alive; otherwise it stays dead.
All births and deaths happen simultaneously based on the current generation.
Input format
Line 1: two integers R and C.
Next R lines: each a string of exactly C characters, each 0 or 1.
Output format
Print R lines, each a string of C characters (0/1): the next generation.
Constraints
- 1 <= R, C <= 60