#P1383F. Special Edges
Special Edges
No submission language available for this problem.
Description
Koa the Koala has a directed graph with nodes and edges. Each edge has a capacity associated with it. Exactly edges of the graph, numbered from to , are special, such edges initially have a capacity equal to .
Koa asks you queries. In each query she gives you integers . This means that capacity of the -th special edge becomes (and other capacities remain the same).
Koa wonders: what is the maximum flow that goes from node to node after each such query?
Help her!
The first line of the input contains four integers , , , (, , , ) — the number of nodes, the number of edges, the number of special edges and the number of queries.
Each of the next lines contains three integers , , (; ) — the description of a directed edge from node to node with capacity .
Edges are numbered starting from in the same order they are listed in the input. The first edges are the special edges. It is guaranteed that for all with .
Each of the next lines contains integers () — the description of the query. denotes the capacity of -th edge.
For the -th query, print one integer — the maximum flow that can be obtained from node to node given the -th query's special edge weights.
Input
The first line of the input contains four integers , , , (, , , ) — the number of nodes, the number of edges, the number of special edges and the number of queries.
Each of the next lines contains three integers , , (; ) — the description of a directed edge from node to node with capacity .
Edges are numbered starting from in the same order they are listed in the input. The first edges are the special edges. It is guaranteed that for all with .
Each of the next lines contains integers () — the description of the query. denotes the capacity of -th edge.
Output
For the -th query, print one integer — the maximum flow that can be obtained from node to node given the -th query's special edge weights.
Samples
Note
For the second sample, the following images correspond to the first two queries (from left to right respectively). For each edge there is a pair flow/capacity denoting flow pushed through the edge and edge's capacity. The special edges are colored in red.

As you can see in first query maximum flow from node to node equals and in second query equals .