while line = gets
    h, w = line.split.map(&:to_i)
    break if h == 0 && w == 0
    for i in 1..h
        if i == 1 || i == h
            for j in 1..w
                print "#"
            end
        else
            print "#"
            for j in 2..(w-1)
                print "."
            end
            print "#"
        end
        puts ""
    end
    puts ""
end