I have some trouble with that problem though it looks like an easy one. I'm not sure if it's a matter of wrong logic, I/O problem (with Python) or just misunderstanding the problem description. "Segment" is a rectangle, right?
For this testcase from a post above:
1
4 5
0 3
2 2
3 3
4 4
0 0 5 5
3 3 4 4
0 0 1 0
0 0 0 1
0 0 0 5
The output should be:
4
2
0
0
1
Right?