P5545 [JSOI2016] Bomb Attack 2

Background

Do you still remember the tower defense game called Bomb Attack? This game now has a sequel, and the bombs are much more powerful.

Description

The game map is a two-dimensional plane. JYY's base is below the $x$-axis, and all enemies are currently above the $x$-axis. In JYY's base, there are $T$ laser towers and $S$ launchers. The coordinates of the $i$-th tower $T_i$ are $(tx_i,ty_i)$, and the coordinates of the $i$-th launcher $S_i$ are $(sx_i,sy_i)$. There are $D$ enemies on the map. The coordinates of the $i$-th enemy $D_i$ are $(dx_i,dy_i)$. Two laser towers can be connected to form an energy wall. If the energy fired from a launcher toward an enemy passes through an energy wall, it can be greatly strengthened, becoming a super ray that instantly destroys the enemy. JYY wants to know how many different attack plans can produce a super ray. Specifically, an attack plan that can produce a super ray is a set of four points: $\{T_i,T_j,S_k,D_l\}$, satisfying $1 \leq i < j \leq T,1 \leq k \leq S,1 \leq l \leq D$, and the line segment $T_iT_j$ intersects the line segment $S_kD_l$. The game guarantees that among these $T+D+S$ points, there are no duplicate points and no three points are collinear.

Input Format

The first line contains a positive integer $D$. The next $D$ lines each contain two integers $dx_i,dy_i$, representing the coordinates of an enemy. Line $D+1$ contains an integer $S$. The next $S$ lines each contain two integers $sx_i,sy_i$, representing the coordinates of a launcher. Line $D+S+1$ contains an integer $T$. The next $T$ lines each contain two integers $(tx_i,ty_i)$, representing the coordinates of a laser tower.

Output Format

Output one line containing one integer: the number of attack plans that can produce a super ray.

Explanation/Hint

For $20\%$ of the testdata, $D,S,T \leq 30$. For $50\%$ of the testdata, $D,S,T \leq 150$. For $100\%$ of the testdata, $1 \leq D,S,T \leq 800, dy_i>0,sy_i,ty_i