Persik — a shark in the world of programming — decided to create a schedule for all tracks of the Innopolis Open olympiad.
There are $$$D$$$ days in the academic year, numbered from $$$1$$$ to $$$D$$$. In total, $$$n$$$ olympiads are held.
The olympiads are numbered from $$$1$$$ to $$$n$$$ in non-decreasing order of their initially scheduled dates. Each olympiad takes place on exactly one day. For each olympiad, its initially scheduled date and its benefit for the younger generation are known.
You may change the date of any olympiad, but only to a later day within the same academic year (that is, the new date cannot be earlier than the original one and cannot exceed $$$D$$$).
After all changes, the olympiads must remain in non-decreasing order of their scheduled dates.
The total benefit of the olympiad season is defined as follows. For each day, consider all olympiads scheduled on that day. If at least one olympiad is scheduled on a given day, the benefit of that day is the maximum benefit among those olympiads. If no olympiads are scheduled on that day, the benefit of that day is $$$0$$$.
The benefit of the season is the sum of the benefits over all $$$D$$$ days.
For the benefit of the students, determine the maximum possible total benefit of the season.
The first line contains three integers $$$n$$$, $$$D$$$, and $$$t$$$ — the number of olympiads and the number of days in the academic year, as well as the type of answer ($$$1 \le n \le 3 \cdot 10^5$$$; $$$1 \le D \le 2 \cdot 10^9$$$; $$$1 \le t \le 2$$$).
In the $$$i$$$-th of the following $$$n$$$ lines, two integers $$$d_i$$$ and $$$b_i$$$ are given — the scheduled date (day number) of the $$$i$$$-th olympiad and its benefit ($$$1 \le d_i \le D$$$; $$$1 \le b_i \le 2 \cdot 10^9$$$).
It is guaranteed that $$$d_i \le d_j$$$ for all $$$i$$$ and $$$j$$$ such that $$$i \lt j$$$.
If $$$t = 1$$$, output a single integer — the maximum possible benefit of the olympiad season.
If $$$t = 2$$$, then in the first line output a single integer — the maximum possible benefit of the olympiad season; and in the second line output the schedule of the olympiads — $$$n$$$ integers, where the $$$i$$$-th is the final date of the $$$i$$$-th olympiad. The specified final dates must achieve the maximum possible benefit of the olympiad season.
The tests for this problem consist of thirteen groups. Points for each group are awarded only if all tests of the group and all tests necessary for it are passed.
| Group | Points | Additional constraints | Necessary groups |
| 1 | 10 | $$$n, D \le 20$$$; $$$b_i \le 20$$$ for all $$$i$$$; $$$t = 1$$$ | – |
| 2 | 7 | $$$n, D \le 20$$$; $$$b_i \le 20$$$ for all $$$i$$$ | 1 |
| 3 | 11 | $$$n, D \le 100$$$; $$$b_i \le 100$$$ for all $$$i$$$ | 1, 2 |
| 4 | 9 | $$$n, D \le 800$$$; $$$b_i \le 800$$$ for all $$$i$$$ | 1, 2, 3 |
| 5 | 5 | $$$n, D \le 2500$$$; $$$b_i \le 2500$$$ for all $$$i$$$; $$$t = 1$$$ | 1 |
| 6 | 4 | $$$n, D \le 2500$$$; $$$b_i \le 2500$$$ for all $$$i$$$ | 1–5 |
| 7 | 5 | $$$b_i = b_j$$$ for all $$$i$$$, $$$j$$$ | – |
| 8 | 5 | $$$d_i \neq d_j$$$ for all $$$i$$$ and $$$j$$$, such that $$$i \neq j$$$ | – |
| 9 | 5 | $$$d_i = 1$$$ for all $$$i$$$; $$$t = 1$$$ | – |
| 10 | 5 | $$$d_i = d_j$$$ for all $$$i$$$, $$$j$$$ | 9 |
| 11 | 8 | $$$D \le 2 \cdot 10^6$$$ | 1–6 |
| 12 | 10 | $$$t = 1$$$ | 1, 5, 9 |
| 13 | 16 | – | 1–12 |
3 10 11 31 51 2
10
3 10 21 31 51 2
10 1 2 3
5 6 21 72 65 85 96 4
30 1 3 5 6 6
Note that the answer for the second test will not be suitable as an answer for the first, as for $$$t = 1$$$ only one number needs to be output.
In the second example, the benefit of the first day is $$$3$$$, the benefit of the second is $$$5$$$, the third is $$$2$$$, and the benefits of days from the $$$4$$$th to the $$$10$$$th are $$$0$$$. Thus, the benefit of the olympiad season is $$$3+5+2+0+\ldots+0=10$$$. Note that the schedule of olympiads $$$[2, 1, 3]$$$ is not possible, as the olympiads must remain in non-decreasing order of their scheduled dates.
In the third example, a schedule of olympiads $$$[1, 2, 5, 6, 6]$$$ is also suitable, but $$$[1, 2, 3, 5, 6]$$$ is not suitable, as the third olympiad cannot take place before the $$$5$$$th day
| Name |
|---|


