while hws = gets.chomp
    h,w = hws.split(' ').map{|n| n.to_i}
    if h==0 && w==0
        break
    else
        puts "#"*w
        (h-2).times do
            puts "#" + "."*(w-2) + "#"
        end
        puts "#"*w
        puts ""
    end
end