while true do
	h,w = gets.split.map(&:to_i)
	if h == 0 && w == 0
		break
	end
	r = "#" * w
	puts r
	t = 0
		while t < h-2
			puts "#" + "." * (w - 2) + "#"
			t = t + 1 
		end
	r = "#" * w
	puts r
	puts ""
end

