
h, w = gets.split.map(&:to_i)
while (h != 0 && w != 0)
puts "#" * w
 (h-2).times{
     print "#" * w
     puts  puts "#" + "." * (w - 2) + "#"
}
puts "#" * w
puts
 
 h, w = gets.split.map(&:to_i)
end


