INS14K - Digo Goes Training

Digo is being trained for shooting as it is a very integral part of his missions. His trainer sets up a training arena for him to practice for it. Digo is taken to the ground where many strong penetrable walls are placed in arbitrary manner. Consider the ground to be a rectangular grid with cartesian coordinates. Digo fires the bullets from a given point on the X-axis. The bullets can only travel parallel to the Y-axis. Given the endpoints of the walls and Digo's current position on the X-axis, he wants to know how many walls he will penetrate with each shot. The shots will only penetrate the wall, they are not powerful enough to break them. As he is very weak in mathematics, he asks you to help him.

Input

The first line consists of the number of test cases, T. The second line contains the number of walls N. Then N lines follow, each line contains 4 integers denoting the end-points of the walls i.e. x1 y1 x2 y2. Next line denotes Q, the number of queries. Queries can be of two types:

  • 1 x1 y1 x2 y2 : which denotes the endpoints of new wall placed.
  • 0 pos : where pos tells about the x coordinate of Digo’s position. The position will be a floating point number, having exactly two digits after the decimal place.

Output

For each query of the type ‘0 pos’ output the numbers of walls penetrated.

Constraints

1 <= T <= 10
1 <= N <= 1000
1 <= Q <= 1000
0 <= x1, y1, x2, y2 <= 20000
0.00 <= pos <= 20000.00

Sample

Input:
1
3
3 5 7 8
1 3 5 6
2 4 8 9
4
0 6.73
1 4 7 9 8
1 2 5 6 3
0 3.55

Output:
2
4

Added by:Surya Kiran
Date:2014-03-20
Time limit:5s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Insomnia 2014

hide comments
2015-03-31 22:37:46 Tony Stark
Anishhhhhhh Kumaaaar Deyyyyyyyyyy! <3
2015-01-19 17:43:08 Abhinandan Agarwal
AC in 1st GO
2015-01-07 19:54:56 Anubhav Gupta
Easy problem :)
2015-01-07 12:39:48 Sarthak Taneja
giving correct ans on my computer but here wrong answer
any more testcases can you suggest
2014-10-31 21:51:21 Anup AK
AC in 1st go!!!
2014-06-04 14:32:51 Bhavik
@parag: it will count as penetration(i assumed that)
2014-05-02 10:30:43 parag agrawal
@Surya: Is it an integer or not? If it is, then hitting exactly the end point should be considered as a penetration or not?

Last edit: 2014-05-02 10:31:28
2014-03-24 18:04:54 ήάέέϻ Ÿ
@Surya: please check my submission. whats wrong with that?
2014-03-23 20:46:26 Surya kiran
@Jacob : It can be an integer also
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.