loop do
	h, w = gets.split.map(&:to_i)
	
	break if h == 0 && w == 0

	h.times do |y|
		w.times do |x|
			if y == 0 || x == 0 || y == h-1 || x == w-1 then
				print '#'
			else
				print '.'
			end
		end
		print "\n"
	end

	print "\n"
end