while true do
    h, w = gets.split.map(&:to_i)
    break if h == 0 && w == 0
    w.times {print "#"}
    puts
    (h - 2).times do
        print "#"
        (w - 2).times {print "."}
        puts "#"
    end
    w.times {print "#"}
    puts
    puts
end
