while 1 do
a,b=gets.split.map(&:to_i)
if a!=0 || b!=0 then
for b in 1..b do
print "#"
end
print "\n"
for a in 2..(a-1) do
print "#"
for i in 1..(b-2) do
print "."
end
print "#\n"
end
for i in 1..b do
print "#"
end
print "\n\n"
else break
end
end