Picture by GuillaumePreat on Pixabay, cc0
One hundred years from now, in
, the International Collegiate
Programming Contest (of which the NCPC is a part) has expanded
significantly and it is now the Galactic Collegiate Programming
Contest (GCPC).
This year there are
teams in the contest. The teams are numbered , and your favorite
team has number .
Like today, the score of a team is a pair of integers
where is the number of solved problems
and is the total
penalty of that team. When a team solves a problem there is
some associated penalty (not necessarily calculated in the same
way as in the NCPC – the precise details are not important in
this problem). The total penalty of a team is the sum of the
penalties for the solved problems of the team.
Consider two teams and whose scores are and . The score of team
is better than that
of if either
, or if
and . The rank of a team is
where is the number of teams whose score
is better.
You would like to follow the performance of your favorite
team. Unfortunately, the organizers of GCPC do not provide a
scoreboard. Instead, they send a message immediately whenever a
team solves a problem.
Input
The first line of input contains two integers and , where is the number of
teams, and is the number of events.
Then follow lines
that describe the events. Each line contains two integers
and ( and ), meaning that team has solved a problem with penalty
. The events are
ordered by the time when they happen.
Output
Output lines. On
the ’th line, output
the rank of your favorite team after the first events have happened.
Sample Input 1 |
Sample Output 1 |
3 4
2 7
3 5
1 6
1 9
|
2
3
2
1
|