w, h, c = gets.chomp.split
w = w.to_i
h = h.to_i
l1 = [?+] + [?-] * (w - 2) + [?+]
l2 = [?|] + [?.] * (w - 2) + [?|]
a = [l1] + [l2] * (h - 2) + [l1]
a[h / 2] = a[h / 2].dup
a[h / 2][w / 2] = c
a.each {|r| puts r.join}
