w, h, c = gets.chomp.split
w, h = w.to_i, h.to_i
flag = Array.new(h)
flag[0] = flag[-1] = "+" + "-" * (w - 2) + "+"
1.upto(h - 2){|i| flag[i] = "|" + "." * (w - 2) + "|"}
flag[h / 2][w / 2] = c
flag.each{|f| puts f}
