loop do
	h, w = gets.split.map{ |s| s.to_i }
	break if h == 0 && w == 0
	h.times do |y|
		w.times do |x|
			if x == 0 || y == 0 || w-x == 1 || h-y == 1
				print "#"
			else
				print "."
			end
		end
		puts
	end
	puts
end