inputs = []
loop do
    input = gets.split(" ")
    input.map!(&:to_i)
    if input[0] == 0 && input[1] == 0; break; end
    inputs << input
end
inputs.each do |input|
    input[0].times do |h|
        input[1].times do |w|
            if h == 0 || h == input[0]-1 || w == 0 || w == input[1]-1
                print "#"
            else
                print "."
            end
        end
        print "\n"
    end
    print "\n"
end
