fun main(args : Array<String>) {
    val (h, w) = readLine()!!.split(' ').map(String::toInt)
    val s = Array(h) { readLine()!! }
    for (i in 0 .. h - 1) {
        val sb = StringBuilder("")
        for (j in 0 .. w - 1) {
            sb.append(if (s[i][j] == '#' || isBlue(i, j, h, w)) '#' else '.')
        }
        println(sb)
    }
    println()
    for (i in 0 .. h - 1) {
        val sb = StringBuilder("")
        for (j in 0 .. w - 1) {
            sb.append(if (s[i][j] == '#' || !isBlue(i, j, h, w)) '#' else '.')
        }
        println(sb)
    }
}

fun isBlue(i : Int, j : Int, h : Int, w : Int) : Boolean {
    return j == 0 || j != w - 1 && i % 2 == 0
}