#include<bits/stdc++.h>
using namespace std;

#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
const int N=500+5;
char a[N][N];
bool b[N][N];

int main()
{
	//freopen("1.in","r",stdin);
	int n,m;
	cin>>n>>m;
	rep(i,1,n)scanf("%s",a[i]+1);
	rep(i,1,n)
	rep(j,1,m)b[i][j]=i==1||i==n||j==1||j==m;
	rep(i,2,n-1)
	{
		bool have_=0;
		rep(j,2,m-1)have_|=a[i][j]=='#';
		bool now=have_?(b[i-1][2]^1):0;
		rep(j,2,m-1)b[i][j]=now;
	}
	per(c,1,0)
	{
		rep(i,1,n)
		{
			rep(j,1,m)putchar((a[i][j]=='#'||b[i][j]==c)?'#':'.');
			puts("");
		}
		puts("");
	}
}