
2024 · Task 2
Advent in Zagreb
Having stuffed himself with sarma (cabbage rolls), Ivan headed off to the Advent market with a clear plan: he wants to taste all the food on offer, but with as little walking around town as possible. As soon as he arrived, however, he faced yet another challenge - prices have shot up compared with last year. On a limited budget, he has to choose carefully which stalls to buy from.
The stalls are laid out in a plane like points in a coordinate system, and the distance between them is calculated using the Euclidean distance. Each stall offers a particular type of food at a fixed price. Ivan's goal is to try one portion of every type of food with minimal walking, starting from the first stall he visits, while making sure he stays within his budget.
Input
The first line contains N, M, B (1 ≤ N ≤ 100 000, 1 ≤ M ≤ 1 000, 1 ≤ B ≤ 1 000 000) - the number of stalls, the number of different types of food, and Ivan's budget.
Each of the next N lines contains four numbers:
- The coordinates of the stall (xi, yi), where xi, yi are real numbers (-103 ≤ xi, yi ≤ 103)
- The type of food the stall offers ti (1 ≤ ti ≤ M)
- The price of the food ci (1 ≤ ci ≤ 15)
Output
On a single line, print the indices (0-indexed) of the stalls Ivan should visit, in the order he visits them.
Example
Input
6 3 10
0 0 1 5
1 1 2 1
2 2 3 5
3 3 1 1
4 4 2 5
5 5 3 1
Output
1 3 5
Explanation: Ivan will visit the 2nd, 4th and 6th stalls and so try all the food, spending only 3 euros and covering a distance of 5.66. If, for example, Ivan visited the 2nd, 3rd and 5th stalls, he would cover a distance of only 4.24, but he would spend 11 euros and go over budget, which would make the solution invalid.