while true do
    h,w = gets.split.map(&:to_i)
    break if h ==0 && w ==0
    h.times do |i|
        str = ''
        w.times do |j|
            if i == 0 || i == h-1 then
                str += '#'
            elsif j == 0 || j == w-1 then
                str += '#'
            else
                str += '.'
            end
        end
        puts str
    end
    puts
end
