while true do
    h, w = gets.split.map(&:to_i)
    break if h == 0 && w == 0
    for i in 1..h do
        for x in 1..w do
            if i != 1 && i != h && x != 1 && x != w then
                print "."
            else
                print "#"
            end
        end
        puts ""
    end
    puts ""
end