#include <bits/stdc++.h>
using namespace std;
int m,n;
char a[505][505];
int main(){
	cin >> m >> n;
	for(int i = 1; i <= m; i++)
		for(int j = 1; j <= n; j++)
			cin >> a[i][j];
	for(int i = 1; i <= m; i++){
		for(int j = 1; j <= n; j++)
			if(i != m && (i == 1 || j%2 == 0)) cout << '#';
			else cout << a[i][j];
		cout << endl;
	}
	cout << endl;
	for(int i = 1; i <= m; i++){
		for(int j = 1; j <= n; j++)
			if(i != 1 && (i == m || j%2 == 1)) cout << '#';
			else cout << a[i][j];
		cout << endl;
	}
	return 0;
}
