There is a directed road network with $$$N$$$ nodes and $$$M$$$ weighted edges, where you are at node $$$1$$$. Your car has battery capacity $$$C$$$, and also starts with $$$C$$$ battery.
Each edge in the graph either increases or decreases your battery when you traverse it. When you have $$$x$$$ battery, you can traverse an edge with weight $$$w$$$ if and only if $$$x \geq w$$$. After traversing such an edge, you will have $$$\min(C, x - w)$$$ battery. Some edges may even be negative, thus increasing your battery.
You want to know the following: which nodes can you reach from your starting node? For each node you can reach, what is the maximum amount of battery you can have when you reach it?
The first line contains $$$T(1 \le T \le 50)$$$, the number of testcases. Then the test cases follow, each with the following format:
For each testcase, print $$$N$$$ space-separated integers on a new line. The $$$i^{\text{th}}$$$ of these integers should denote the maximum possible battery you can have when you reach node $$$i$$$, or $$$-1$$$ if it is impossible.
26 6 111 2 31 3 22 3 53 4 44 5 74 6 16 6 111 3 21 2 32 3 53 4 -94 5 124 6 10
11 8 9 5 -1 4 11 8 9 11 -1 1
| Name |
|---|


