h, w = gets.split.map(&:to_i)
while h != 0 || w != 0 do
	
		for b in 1..w do
			print "#{}"
			puts
		end
	for a in 1..(h-2) do
		print"#"
		for b in 1..(w-2) do
			print "."
		end
		print"#"
		puts
		for b in 1..w do
			print "#"
			puts
		end
	end
h, w = gets.split.map(&:to_i)
puts
end