#include
using namespace std;
bool ratinmaze(char grid[][20], int n, int m,int sol[][20], int i, int j ){
if( i == n && j == m){
sol[i][j] = 1;
for( int i = 0; i<= n; i++){
for( int j = 0; j<=m; j++){
cout << sol[i][j] << " ";
}
cout << endl;
}
return true;
}
if( i > m || j > n){
return false;
}
if( grid[i][j] == 'X'){
return false;
}
sol[i][j] = 1;
bool rightsuccess = ratinmaze(grid,m,n,sol,i,j+1);
bool downsuccess = ratinmaze(grid,m,n,sol,i+1,j);
sol[i][j] =0;
return true;
}
int main() {
int n, m;
cin >> n>>m;
char grid[20][20];
for( int i = 0; i < n; i++){
for( int j = 0; j < m; j++){
cin >> grid[i][j];
}
}
int sol[20][20] ={0};
ratinmaze(grid,m-1,n-1,sol,0,0);
return 0;
}