N, K = gets.split.map(&:to_i) A = Array.new(N) { gets.chomp } B = [] b = "#" * K w = "." * K N.times do |i| row = "" N.times do |j| row << (A[i][j] == ?# ? b : w) end K.times do B << row end end puts B.join("\n")