You are given a weighted directed graph with $$$n$$$ vertices and $$$m$$$ edges. Each vertex in the graph can be either highlighted or normal. Initially, all vertices are normal. The cost of the graph is defined as the minimum sum of edge weights that need to be selected so that from each normal vertex one can reach at least one highlighted vertex using the selected edges only. If it is not possible to select the edges, the cost is $$$-1$$$ instead.
Your task is to compute the cost of the graph after each of the $$$q$$$ queries. The queries can be of two types:
Output the cost of the graph after each of the $$$q$$$ queries.
The first line contains three integers $$$n$$$, $$$m$$$, and $$$q$$$ ($$$3 \le n \le 2 \cdot 10^5, 1 \le m, q \le 2 \cdot 10^5$$$) — the number of vertices in the graph, the number of edges, and the number of queries.
The next $$$m$$$ lines contain the edges of the graph, one edge per line. The $$$i$$$-th line contains three integers $$$u_i$$$, $$$v_i$$$, and $$$c_i$$$ ($$$1 \leq u_i, v_i \leq n, u_i \ne v_i, 1 \leq c_i \leq 10^6$$$) — the endpoints of the $$$i$$$-th edge (from $$$u_i$$$ to $$$v_i$$$) and its weight ($$$c_i$$$).
The next $$$q$$$ lines contain the queries, one query per line. The $$$i$$$-th line contains $$$+\;v_i$$$, if it is a query of the first type, and $$$-\;v_i$$$, if it is a query of the second type ($$$1 \leq v_i \leq n$$$).
Output $$$q$$$ numbers. The $$$i$$$-th number is the cost of the graph after the first $$$i$$$ queries.
4 5 61 2 12 3 53 2 34 1 82 1 4+ 1- 1+ 3+ 1+ 4+ 2
15 -1 14 12 4 0
10 14 108 6 42 5 13 5 41 6 31 3 77 2 16 1 34 10 14 6 55 4 15 8 1010 9 19 5 19 7 6+ 7+ 8- 7+ 10+ 2- 10+ 5- 2- 5+ 3
28 24 29 19 18 24 18 19 29 20
In the first test:
Name |
---|