5 8 3 80 100 1 2 20 1 3 70 2 1 30 2 5 10 3 2 10 3 4 30 3 5 20 5 1 70
1 5 The given graph is as shown in the left figure below. The cost of each edge is shown near the starting vertex of that edge.  Here, the following holds: * For the path from vertex $1$ to vertex $1$, consider vertex $1$ $\to$ vertex $2$ $\to$ vertex $5$ $\to$ vertex $1$ (center of the figure above). This traverses exactly three edges, and the sum of the costs of the traversed edges is $20+10+70=100$, so it satisfies the condition. * There is no path from vertex $1$ to vertex $2$ that satisfies the condition. One path that traverses exactly three edges is vertex $1$ $\to$ vertex $2$ $\to$ vertex $1$ $\to$ vertex $2$, but the sum of the costs of the edges traversed in this path is $20+30+20=70$, which is less than $80$, so it does not satisfy the condition. * There is no path from vertex $1$ to vertex $3$ that satisfies the condition. One path that traverses exactly three edges is vertex $1$ $\to$ vertex $2$ $\to$ vertex $1$ $\to$ vertex $3$, but the sum of the costs of the edges traversed in this path is $20+30+70=120$, which is greater than $100$, so it does not satisfy the condition. * There is no path from vertex $1$ to vertex $4$ that satisfies the condition. * For the path from vertex $1$ to vertex $5$, consider vertex $1$ $\to$ vertex $3$ $\to$ vertex $2$ $\to$ vertex $5$ (right of the figure above). This traverses exactly three edges, and the sum of the costs of the traversed edges is $70+10+10=90$, so it satisfies the condition. Therefore, print $1$, $5$ in this order. Note that you need to print those vertices that satisfy the condition in ascending order.
10 1 1 1 100 2 3 1
If there are no vertices that satisfy the condition, print an empty line.
2 5 3 1 100 1 1 1 2 2 100 1 2 1 1 2 1 1 2 100
1 2 The graph may contain self-loops and multiple edges. In this test case, the out-degrees from vertices $1$ and $2$ are $4$ and $1$, respectively.
{
"problem": {
"name": "Paid Walk",
"description": {
"content": "There is a directed graph (not necessarily simple) with $N$ vertices and $M$ edges, where the vertices are numbered as vertices $1, 2, \\ldots, N$. The $i$\\-th $(1\\leq i\\leq M)$ edge goes from vertex",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 2000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "abc441_d"
},
"statements": [
{
"statement_type": "Markdown",
"content": "There is a directed graph (not necessarily simple) with $N$ vertices and $M$ edges, where the vertices are numbered as vertices $1, 2, \\ldots, N$. \nThe $i$\\-th $(1\\leq i\\leq M)$ edge goes from vertex...",
"is_translate": false,
"language": "English"
}
]
}