import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

immutable int Dirs = 4;
immutable int [Dirs] DCol = [+1,  0, -1,  0];
immutable int [Dirs] DRow = [ 0, +1,  0, -1];

void main ()
{
	int h, w;
	while (readf (" %s %s", &h, &w) > 0)
	{
		readln;
		char [] [] a;
		foreach (row; 0..h)
		{
			a ~= readln.strip.dup;
		}

		auto build (int row, int col, int [2] s)
		{
			auto res = new char [] [] (h, w);
			foreach (ref x; res)
			{
				x[] = '.';
			}
			int b = 0;
			int dir = 0;
			if (col >= 0)
			{
				res[row][col] = '#';
			}
			while (s[b] > 0)
			{
				foreach (step; 0..s[b])
				{
					row += DRow[dir];
					col += DCol[dir];
					if (col >= 0)
					{
						res[row][col] = '#';
					}
				}
				dir = (dir + 1) & (Dirs - 1);
				s[b] -= 2;
				if (s[b] < 0)
				{
					break;
				}
				b ^= 1;
			}
			return res;
		}

		char [] [] b = build (0, -2, [w + 1, h - 1]);
		char [] [] c = build (1, -1, [w - 1, h - 3]);

		foreach (row; 0..h)
		{
			foreach (col; 0..w)
			{
				if (a[row][col] == '#')
				{
					b[row][col] = '#';
					c[row][col] = '#';
				}
				else
				{
					assert (b[row][col] != '#' ||
					    c[row][col] != '#');
				}
			}
		}

		writefln ("%-(%s\n%)", b);
		writeln;
		writefln ("%-(%s\n%)", c);
	}
}
