while true
	h, w = gets.split( " " ).map { | val | val.to_i }
	break if 0 == h && 0 == w
	
	h.times { | i |
		if 0 == i || h-1 == i
			puts( "#"*w )
		else
			puts( "#"+"."*(w-2)+"#" )
		end
	}
	print( "\n" )
end