
loop do
    h, w = gets.split(" ").map(&:to_i)

    if h == 0 && w == 0 then
        break;
    end
    
    # #........#
    
    h.times do |i|
        if i == 0 || i == h - 1 then
            print "#" * w, "\n"
        else
            print "#", "." * (w - 2), "#\n"
        end
    end
    
    print "\n"
end
