#include <iostream>
#include <fstream>
using namespace std;
const int nmax=1005;
string s[nmax],ans1[nmax],ans2[nmax];
int n,m,i,j;
int main()
{
    //freopen("data.in","r",stdin);
    cin>>n>>m;
    for(i=1;i<=n;i++)
        cin>>s[i];
    for(i=1;i<=n;i++)
        ans1[i]=ans2[i]=s[i];
    for(i=1;i<=n;i++)
        ans1[i][0]=ans2[i][m-1]='#';
    for(i=1;i<=n;i+=2)
        for(j=1;j<m-1;j++)
            ans1[i][j]='#';
    for(i=2;i<=n;i+=2)
        for(j=1;j<m-1;j++)
           ans2[i][j]='#';
    for(i=1;i<=n;i++)
        cout<<ans1[i]<<'\n';
    cout<<'\n';
    for(i=1;i<=n;i++)
        cout<<ans2[i]<<'\n';
    return 0;
}
