#include<cstdio>
using namespace std;
const int N=550;
int i,j,k,n,m;
char a[N][N],b[N][N];
int main() {
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++) {
		scanf("%s",a[i]+1);
		for (j=1;j<=m;j++) b[i][j]=a[i][j];
	}
	for (i=1;i<=n;i++) a[i][1]=b[i][m]='#';
	for (i=2;i<n;i+=2)
		for (j=2;j<m;j++) a[i][j]='#';
	for (i=3;i<n;i+=2)
		for (j=2;j<m;j++) b[i][j]='#';
	for (i=1;i<=n;i++) printf("%s\n",a[i]+1);
	puts("");
	for (i=1;i<=n;i++) printf("%s\n",b[i]+1);
}