while true
    h, w = gets.chomp.split.map(&:to_i)
    break if h == 0 && w == 0

    h.times{|y|
        w.times{|x|
            if y == 0 || y == h - 1 || x == 0 || x == w - 1 
                print "#"
            else
                print "."    
            end
        }
        puts
    }
    puts
end