Baker Crumble has just baked triangular burek pastries. Each pastry can be represented in the Cartesian coordinate system as a triangle with vertices in integer coordinate points.
The baker's mischievous son Joey has just taken a large knife and started to cut the pastries. Each cut that Joey makes corresponds to a horizontal or vertical line in the coordinate system. Help the baker assess the damage caused by Joey's pastry cutting. Your task is to determine, for each Joey's cut, how many pastries are affected (such that both the left and right parts of the cut pastry have areas greater than zero).
Input Specification
The first line of input contains the positive integer , the number of burek pastries.
Each of the following lines contains six nonnegative integers smaller than . These numbers are, in order, the coordinates of the three pastry-triangle vertices. The three vertices will not all be on the same line. The pastries can touch as well as overlap.
The following line contains the positive integer , the number of cuts.
Each of the following lines contains a single cut line equation: or (note the spaces around the equals sign), where is a nonnegative integer smaller than .
Output Specification
For each cut, output a line containing the required number of cut pastries.
Scoring
In test data worth at least points, .
In test data worth an additional points, the vertex coordinates of all triangles will be smaller than .
Sample Input 1
3
1 0 0 2 2 2
1 3 3 5 4 0
5 4 4 5 4 4
4
x = 4
x = 1
y = 3
y = 1
Sample Output 1
0
1
1
2
Sample Input 2
4
2 7 6 0 0 5
7 1 7 10 11 11
5 10 2 9 6 8
1 9 10 10 4 1
4
y = 6
x = 2
x = 4
x = 9
Sample Output 2
3
2
3
2
Comments