#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;

const int N=1005;
const ll inf=1000000000000000000ll;

int n,m;
char c[2][N][N];

int main(){
	int i,j;
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++){
		scanf("%s",c[0][i]+1);
		for (j=1;j<=m;j++) c[1][i][j]=c[0][i][j];
	}
	for (i=2;i<n;i++)
		for (j=2;j<m;j++) c[i&1][i][j]='#';
	for (i=1;i<=n;i++) c[0][i][1]='#',c[1][i][m]='#';
	for (i=1;i<=n;i++){
		for (j=1;j<=m;j++) printf("%c",c[0][i][j]);
		printf("\n");
	}
	printf("\n");
	for (i=1;i<=n;i++){
		for (j=1;j<=m;j++) printf("%c",c[1][i][j]);
		printf("\n");
	}
	return 0;
}