// Arup Guha
// 11/3/2018
// Solution to 2018 SER D2 Problem: Sculpture

import java.util.*;

public class sculpture {
	
	// Border squares.
	final public static int[] DX = {-1,0,0,1};
	final public static int[] DY = {0,-1,1,0};
	
	public static void main(String[] args) {
		
		// Read in the grid.
		Scanner stdin = new Scanner(System.in);
		int r = stdin.nextInt();
		int c = stdin.nextInt();
		int[][] grid = new int[r][c];
		for (int i=0; i<r; i++)
			for (int j=0; j<c; j++)
				grid[i][j] = stdin.nextInt();
		
		int[][] res = new int[r][c];
		
		// Go through all valid squares.
		for (int i=1; i<r-1; i++) {
			for (int j=1; j<c-1; j++) {
				
				// Count how many are higher around you.
				int cnt = 0;
				for (int k=0; k<DX.length; k++)
					if (grid[i][j] < grid[i+DX[k]][j+DY[k]])
						cnt++;
				
				// Need a drain!
				if (cnt == 4) res[i][j] = 1;
			}
		}
		
		// Print the grid.
		for (int i=0; i<r; i++) {
			for (int j=0; j<c-1; j++)
				System.out.print(res[i][j]+" ");
			System.out.println(res[i][c-1]);
		}
	}
}
