lines = readlines.map(&:chomp).map{|line| line.split.map(&:to_i)}
lines.each do |line|
    break if line == [0, 0]
    line[0].times do |i|
        line[1].times do |j|
            if i == 0 || i == line[0]-1 || j == 0 || j == line[1]-1 then
                print "#"
            else
                print "."
            end
        end
        puts
        end
    puts
end
