def draw_frame_line(h, w, i)
	if i==1 || i==h
		w.times{print("#")}
	else
		print("#")
		(w-2).times{print(".")}
		print("#")
	end
	puts ""
end
def draw_frame(h, w)
	for i in 1..h
		draw_frame_line(h, w, i)
	end
	puts ""
end

inputs = gets.strip().split(" ")
h  = inputs[0].to_i
w  = inputs[1].to_i

until h == 0 && w == 0
	draw_frame(h, w)
	inputs = gets.strip().split(" ")
	h  = inputs[0].to_i
	w  = inputs[1].to_i		
end
