while true do
    i = gets
    h = i.split[0].to_i
    w = i.split[1].to_i
    break if h == 0 && w == 0
    w.times {print "#"}
    print "\n"
    (h-2).times do
        print "#"
        (w-2).times {print "."}
        print "#"
        print "\n"
    end
    w.times {print "#"}
    print "\n\n"
end
