while true do
    h, w = gets.split(" ").map(&:to_i)
    if h && w == 0
        break
    end
    a = h - 2
    b = w - 2

    puts "#" * w
    i = 0
    while i < a do
        puts ("#" + "." * b + "#")
        i = i + 1
    end
    puts "#" * w

    puts
end