The box with the hinged lid is to be made out of the piece of cardboard which measures 20 by 40 inches. 6 squares, x inches on the side, will be cut out from every 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 volume of 500 cubic inches.