Editorial- LINESNDOTS

Problem Link- CodeChef: Practical coding for everyone

There are ^aC_2 ways to choose two points from the first row (order doesn’t matter), and ^bC_2 ways to choose two points from the second row.

Every choice of two points from the first row and two points from the second row corresponds to exactly one point of intersection (namely, the intersection of diagonals of the convex quadrilateral built on them). And conversly, each point of intersection corresponds to two pairs of points from first row and second row respectively (namely, the endpoints of intersecting segments).

Hence, we have a bijection, and the total number of points of intersection is:

^aC_2 . ^bC_2=a*b*(a-1)*(b-1)/4