Under construction

Still being built. Things may change

Shimmer Production

Time limit2.5sMemory limit1024 MB

Summary
Pick at most k machines, each reached by shortest path from vertex 1, so that V components finish as early as possible; output that minimum time.
Level

Medium7 of 10

Topics
Shortest path, Binary search, Greedy
Solved
No attempts yet

Problem

Silco needs special machines to synthesize Shimmer. Before using them, the machines must be obtained in the city and delivered to the factory.

The city is a weighted undirected graph with nn vertices and mm edges. The factory is at vertex 11. Some vertices contain machines. The ii-th machine is described by a triple (vi,hi,ti)(v_i, h_i, t_i), where viv_i is the vertex the machine is in, hih_i is the time needed to install and warm up the machine, and tit_i is the rate at which the machine produces Shimmer components.

Silco has kk free couriers. Each courier can bring one machine. A courier who has delivered a machine must lie low and cannot go for more machines. So Silco can deliver at most kk machines to the factory.

All couriers start at the factory at time 00. To reach a machine, a courier needs time equal to the sum of edge weights on the shortest path to the vertex containing that machine. If a machine is in vertex 11, delivering it takes no time, but it still requires one courier.

When a machine arrives at the factory, it first spends hih_i time units on preparation, after which it produces one component every tit_i time units. What is the minimum time needed to produce VV components?

Input

The first line contains three integers nn, mm, and kk, the number of vertices, the number of edges, and the number of couriers (2≤n,m,k≤2⋅1052 \leq n, m, k \leq 2 \cdot 10^5).

The next mm lines each contain three integers aia_i, bib_i, and cic_i, meaning that an edge of weight cic_i connects vertices aia_i and bib_i (1≤ai,bi≤n1 \leq a_i, b_i \leq n; ai≠bia_i \neq b_i; 1≤ci≤1091 \leq c_i \leq 10^9). All listed edges are distinct.

The next line contains a single integer ss, the number of machines in the city (1≤s≤2⋅1051 \leq s \leq 2 \cdot 10^5).

Each of the next ss lines describes one machine with three integers viv_i, hih_i, and tit_i: the vertex containing the machine, its warm-up time, and the time it takes to produce one component (1≤vi≤n1 \leq v_i \leq n; 1≤hi,ti≤1091 \leq h_i, t_i \leq 10^9).

The last line contains a single integer VV, the number of components to produce (1≤V≤1091 \leq V \leq 10^9).

Output

Print a single integer, the minimum time needed to produce VV components.

Examples2

  1. Example 1

    Input
    3 3 2
    1 2 5
    1 3 2
    3 2 2
    3
    1 15 1
    2 1 1
    3 3 2
    10
    
    Expected output
    15
    
  2. Example 2

    Input
    4 4 4
    4 2 5
    1 3 3
    3 4 16
    2 1 9
    10
    3 18 8
    1 2 12
    4 8 19
    2 9 15
    2 12 2
    4 20 4
    3 11 14
    2 5 3
    4 19 1
    1 1 20
    3
    
    Expected output
    26