Intersecting Line Segments

In a 2-D Cartesian space, a straight line segment A is defined by two points A0 = (x0, y0), A1 = (x1, y1). The intersection of line segments A and B (if there is one), together with the initial four points, defines four new line segments. In Figure 1.1, the intersection P between lines B and C defines four new segments. As a result, the toal amount of line segments after the evaluation of intersections is five. Given an initial set of lines segments, determine the number of line segments resulting from the eval- uation of all the possible intersections. It is assumed, as a simplification, that no coin- cidences may occur between coordinates of singular points (intersections or end points). Input Figure 1.1 - Intersections of line segments line by itself indicating the number of the cases following, each of them as described below. This line The input begins with a single positive integer on a is followed by a blank line, and there is also a blank line between two consecutive inputs. The first line of the input contains the integer number N of line segments. Each of the following N lines contains four integer values x0 y0 x1 y1, separated by a single space, that define a line segment. Output For each test case, the output must follow the description below. The outputs of two consecutive cases will be separated by a blank line. The integer number of lines segments after all the possible intersections are evaluated. Note: Figure 1.2 corresponds to the sample below. Sample Input 1 5 3138 4148 2494 8757 5 6 10 1 Sample Output 11 Figure 1.2 – Example