
loop do
arr = gets.split.map(&:to_i)
h = arr[0]
w = arr[1]
if h != 0 || w != 0 then

for j in 1..(w-1)
print "#"
end

puts "#"

for i in 2..(h-1)
print "#"
for j in 2..(w-1)
print "."
end
puts "#"
end

for j in 1..(w-1)
print "#"
end

puts "#"
puts ""


else
exit

end

end
