The heated competition of the ACM-ICPC World Finals continues, and The Team is at the top of their game! Well, okay, maybe they're not actually doing so well, according to the scoreboard, yet. But they have a plan!
The contest is taking place in a huge room with a regular grid of desks.
The columns and rows are each numbered
Now, The Team is interested in removing some of the more dangerous
opponents from the competition. To accomplish this, they have a number
of water balloons at their disposal (after all, where in the contest
rules does it say that water balloons are not allowed?). Always
conservative, they would first like to answer
In order to do any real damage, the water balloons will of course have
to be thrown extremely hard - in fact, in a perfectly straight line, and
not over any obstacles besides empty desks. This means that, if team
The members of The Team will need to carefully choose which opponents to take out, based on how well they're doing and how many balloons it would take, so they're already answered all of their queries in their heads. Maybe, if you can answer them as well, you can also adopt such techniques in the future…
Input Specification
First line: 4 integers,
Next
Next
Output Specification
Sample Input
6 6 3 2
5 6 3
2 1 5
4 4 2
4 3 1
5 4 2
7 6 1
6
5
4
3
2
1
Sample Output
4
3
1
2
5
5
Explanation of Sample
The following grid shows the positions of the T
). The line
segments represent direct lines of sight to the opponents.
As can be seen, team 6 is blocked by teams 4 and 5. Therefore, taking
them out would require
Comments