Ambitious Plan

아직 제출이 없습니다시간 제한4초메모리 제한512 MB

문제

Steven Sleepberg is going to produce the forty seventh sequel to his film "Battlefield Jupiter" and is now planning the main battle scene. The script of the scene says that nn empire drones would attack mm republic forts. The attack proceeds as follows: a drone shoots the laser cannon towards one of the forts. The defense in turn has tt power towers, and one pair of towers creates a power shield. The power shield is a segment connecting the two towers. If the shield intersects the segment which connects the shooting drone with its target a spectacular explosion takes place.

Steven wants the scene to be as spectacular as possible. So he wants to film all possible pairs of shoot and shield that cause explosion. Help him to estimate the length of the scene by counting the number of possible explosions.

Let us consider drones, forts and power towers as points on a plane. The line of defense coincides with the line y=0y = 0, so yy-coordinates of all forts and towers are less than 0, and yy-coordinates of all drones are greater than 0. You are given coordinates of nn drones, mm forts and tt towers. Find the number of sets D,F,T_1,T_2\\{D, F, T\_1, T\_2\\} such that DD is drone, FF is fort, T_1T\_1 and T_2T\_2 are towers, and segments DFDF and T_1T_2T\_1T\_2 intersect. No two points coincide, no three points are on the same line.

입력

The input file contains multiple test cases.

Each test case starts with nn --- the number of drones (1n15001 \le n \le 1500), nn lines follow, each line contains dx_i,dy_idx\_i, dy\_i --- coordinates of a drone. Integer mm --- the number of forts (1m15001 \le m \le 1500) --- follows, with mm more lines, each line contains fx_i,fy_ifx\_i, fy\_i --- coordinates of a fort. Finally there goes tt --- the number of towers (2t15002 \le t \le 1500) followed by tt lines, each line contains tx_i,ty_itx\_i, ty\_i --- coordinates of a tower.

All drones coordinates satisfy 109dx_i109-10^9\le dx\_i\le 10^9, 0<dy_i1090< dy\_i\le 10^9. All forts and towers coordinates satisfy 109fx_i,tx_i109-10^9\le fx\_i, tx\_i\le 10^9, 109fy_i,ty_i<0-10^9 \le fy\_i, ty\_i < 0.

Input is followed by a line containing a single zero.

The total number of drones in the input file is at most 15001500. The total number of forts in the input file is at most 15001500. The total number of towers in the input file is at most 15001500.

출력

For each test case print one integer: the number of possible pairs of shoot-shield that cause an explosion.