The box with a hinged lid is to be made out of the piece of cardboard which measures 20 by 40 inches. Six squares, x inches on the side, will be cut out from each corner and middle, and then ends and sides will be folded up to form box and its lid. Determine value of x which would result in the box with the volue 500 cubic inches.