using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("5 5");
            WillReturn.Add(".....");
            WillReturn.Add(".#.#.");
            WillReturn.Add(".....");
            WillReturn.Add(".#.#.");
            WillReturn.Add(".....");
            //.....
            //#####
            //#....
            //#####
            //.....
            //
            //.###.
            //.#.#.
            //.#.#.
            //.#.#.
            //.....
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("7 13");
            WillReturn.Add(".............");
            WillReturn.Add(".###.###.###.");
            WillReturn.Add(".#.#.#...#...");
            WillReturn.Add(".###.#...#...");
            WillReturn.Add(".#.#.#.#.#...");
            WillReturn.Add(".#.#.###.###.");
            WillReturn.Add(".............");
            //.............
            //.###########.
            //.###.###.###.
            //.###.###.###.
            //.###.###.###.
            //.###.###.###.
            //.............
            //
            //.............
            //.###.###.###.
            //.#.#.#...#...
            //.###.#...#...
            //.#.#.#.#.#...
            //.#.#########.
            //.............
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();
        int UB_Y = wkArr[0] - 1;
        int UB_X = wkArr[1] - 1;

        char[,] AArr = new char[UB_X + 1, UB_Y + 1];

        for (int Y = 0; Y <= UB_Y; Y++) {
            for (int X = 0; X <= UB_X; X++) {
                AArr[X, Y] = InputList[Y + 1][X];
            }
        }

        //for (int Y = 0; Y <= UB_Y; Y++) {
        //    for (int X = 0; X <= UB_X; X++) {
        //        Console.Write(AArr[X,Y]);
        //    }
        //    Console.WriteLine();
        //}

        char[,] TakahashiArr = new char[UB_X + 1, UB_Y + 1];
        char[,] AokiArr = new char[UB_X + 1, UB_Y + 1];
        for (int Y = 0; Y <= UB_Y; Y++) {
            for (int X = 0; X <= UB_X; X++) {
                TakahashiArr[X, Y] = '.';
                AokiArr[X, Y] = '.';
            }
        }

        for (int Y = 0; Y <= UB_Y; Y++) {
            TakahashiArr[0, Y] = '#';
            AokiArr[UB_X, Y] = '#';
        }

        for (int Y = 0; Y <= UB_Y; Y++) {
            if (Y % 2 == 0) {
                for (int X = 1; X <= UB_X-1; X++) {
                    TakahashiArr[X, Y] = '#';
                }
            }
            if (Y % 2 == 1) {
                for (int X = 1; X <= UB_X - 1; X++) {
                    AokiArr[X, Y] = '#';
                }
            }
        }

        // 紫の個所を埋める
        for (int Y = 0; Y <= UB_Y; Y++) {
            for (int X = 0; X <= UB_X; X++) {
                if (AArr[X, Y] == '#') {
                    TakahashiArr[X, Y] = '#';
                    AokiArr[X, Y] = '#';
                }
            }
        }

        // 解の出力
        for (int Y = 0; Y <= UB_Y; Y++) {
            for (int X = 0; X <= UB_X; X++) {
                Console.Write(TakahashiArr[X, Y]);
            }
            Console.WriteLine();
        }
        Console.WriteLine();
        for (int Y = 0; Y <= UB_Y; Y++) {
            for (int X = 0; X <= UB_X; X++) {
                Console.Write(AokiArr[X, Y]);
            }
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 15072