input = gets.chomp.split("\s")
h, w = input[0].to_i, input[1].to_i

until (h == 0) && (w == 0)
	for i in 1..h
		if (i == 1) || (i == h)
			output = ['#'] * w
			puts output.join
		else
			output = ["#"] + ['.'] * (w - 2) + ["#"]
			puts output.join
		end
	end
	
puts ""
input = gets.chomp.split("\s")
h, w = input[0].to_i, input[1].to_i
end