8. There is a square on the plane, whose sides are parallel to the horizontal and vertical directions. Draw several line segments parallel to the sides of the square such that: no two line segments belong to the same straight line, and any two intersecting line segments intersect at an endpoint of one of the line segments. It is known that the drawn line segments divide the square into several rectangles, and any vertical line intersecting the square but not containing any of the drawn line segments intersects exactly $k$ rectangles, and any horizontal line intersecting the square but not containing any of the drawn line segments intersects exactly $l$ rectangles. Find all possible values of the number of rectangles in the square.
8. The number of rectangles is $k l$.

Prove this conclusion by induction on $k$.
When $k=1$, the conclusion is obviously true.
Assume $k>1$. Since the line segments divide the square into several rectangles, the intersection of any two intersecting line segments is precisely one of the endpoints of one of the line segments.

Consider all rectangles that have the bottom side of the square as their bottom side. These rectangles can be grouped by height into several groups of equal height. The union of the rectangles in each group forms a rectangle, called a "combined rectangle".
Then the following two conclusions hold.
(1) The left, right, and top sides of each combined rectangle form an $\mathrm{H}$ shape;
(2) The number of rectangles with the top side of each combined rectangle as their top side is equal to the number of rectangles with it as their bottom side.

In fact, if the left, right, and top sides of a certain combined rectangle do not form an $\mathrm{H}$ shape, assume without loss of generality that the left and top sides form a T shape, and let the left side be $s$. Then there are at least two rectangles on the left side of $s$ that have it as their right side, indicating that the number of rectangles intersecting with vertical lines near the left side of $s$ is more than the number of rectangles intersecting with vertical lines on the right side, which is a contradiction.
Similarly, prove conclusion (2).
Move the top side of the combined rectangle (if this combined rectangle is not the shortest in height) downward to make its height equal to the minimum height. During this process, the rectangles above the top side extend downward, and the rectangles below it become shorter. After this process is completed, all combined rectangles have the same height, forming a large combined rectangle that is as wide as the square, containing $l$ rectangles. Removing this large combined rectangle, the remaining shape (called the "new square") satisfies: any vertical line intersecting the new square and not containing any drawn line segments intersects exactly $k-1$ rectangles, and any horizontal line intersecting the new square and not containing any drawn line segments intersects exactly $l$ rectangles.

By the induction hypothesis, the new square contains $(k-1) l$ rectangles.
Therefore, the number of rectangles in the original square is
$$
(k-1) l+l=k l \text {. }
$$