#include <bits/stdc++.h>
using namespace std;
const int N = 510;
string s[N];
int main() {
	int h,w;
	cin >> h >> w;
	for (int i=0;i<h;i++) cin >> s[i];
	for (int j=0;j<w;j++) cout << "#";
	cout << endl;
	for (int i=1;i<h-1;i++) {
		for (int j=0;j<w;j++) {
			if (j%2) cout << "#";
			else cout << s[i][j];
		}
		cout << endl;
	}
	cout << s[h-1] << endl;
	cout << endl;

	cout << s[0] << endl;
	for (int i=1;i<h-1;i++) {
		for (int j=0;j<w;j++) {
			if (j%2 == 0) cout << "#";
			else cout << s[i][j];
		}
		cout << endl;
	}
	for (int j=0;j<w;j++) cout << "#";
	cout << endl;

	return 0;
}