loop do
    h,w = gets.split(" ").map do |i| i.to_i end
    if h + w == 0 then
        break
    else
        (1..h).each do |high|
            (1..w).each do |wide|
                if high == 1 || high == h || wide == 1 || wide == w then
                    print "#"
                else
                    print "."
                end
            end
            puts ""
        end
        puts ""
    end
end