while true
    rect = gets.split.map(&:to_i)
    break if (rect[0] == 0 && rect[1] == 0)
    cen = rect[0]-2
    
    rect[1].times do
        puts "#"
    end
    cen.times do
        print "#"
        print "."
        puts "#"
    end
    rect[1].times do
        puts "#"
    end
    puts
end