def toi(a)
	b = []
	a.each do |n|
		b << n.to_i
	end
	b	
end


while true
a = toi(gets().split)
h = a[0]
w = a[1]

if h == 0 && w == 0
 break
end

for n in 1 .. h
	for m in 1 .. w
		if n == 1 || n == h || m == 1 || m == w
			print("#")
		else
			print(".")
		end
	end
	puts "\n"
end
puts "\n"

end