Tourist Attractions

No attempts yetTime limit3sMemory limit128 MB

Problem

Byteasar travels from Bitingham to Byteburg. Along the way he wants to visit some must-see sites, including interesting monuments, fine restaurants, and numerous other tourist attractions. The order in which he visits the places is not entirely unimportant. For example, Byteasar would rather not climb the peaky tower of Bitfork Castle right after a lavish dinner in Digitest, and likewise he would drop in to Zip City (called by some Sip City) for a cup of the famous Compresso coffee after dinner rather than before. Luckily his tour is, to some extent, flexible, and he can choose between several orders. Because of horrendous petrol prices, he would like to follow the shortest possible route, for economy's sake. Be a good friend and help him determine the length of the shortest route that meets his requirements.

The road network consists of nn sites and mm roads connecting them. The sites are numbered from 11 to nn, and so are the roads (from 11 to mm). Each road links a pair of different sites, is bidirectional, and has a certain length. Different roads meet only at sites (their endpoints) and do not cross outside the sites, thanks to a clever system of flyovers and tunnels. A pair of sites can be connected directly by at most one road, though there can be many paths consisting of at least two direct roads between them.

Let kk denote the number of sites Byteasar wants to visit. Bitingham has number 11, Byteburg has number nn, and the sites Byteasar wants to visit have numbers 2,3,,k+12, 3, \dots, k+1.

An example road network is shown in the figure. Suppose Byteasar wants to visit sites 2,3,42, 3, 4 and 55, and he would like to visit 22 before 33, and 44 and 55 after 33. Then the shortest route leads through sites 1,2,4,3,4,5,81, 2, 4, 3, 4, 5, 8 and its length is 1919.

Note that site 44 appears on the route both before and after site 33. This is perfectly fine and means that Byteasar will not stop there before visiting site 33, since his requirements disallow it. He is, however, allowed to pass through site 44 without stopping before visiting site 33, and this is exactly what he is going to do.

Write a program that:

  • reads from standard input the description of the road network, the list of sites Byteasar has chosen to visit, and the restrictions on the order in which he wants to visit them,
  • determines the length of the shortest route leading in an appropriate order through all the chosen sites,
  • writes the result to standard output.

Input

The first line of standard input contains three integers nn, mm and kk, separated by single spaces, with 2n20,0002 \le n \le 20{,}000, 1m200,0001 \le m \le 200{,}000, 0k200 \le k \le 20; furthermore, kn2k \le n - 2 holds.

The following mm lines contain the descriptions of the roads, exactly one per line. The (i+1)(i+1)-th line contains three integers pip_i, qiq_i and lil_i, separated by single spaces, with 1pi<qin1 \le p_i < q_i \le n and 1li1,0001 \le l_i \le 1{,}000. These numbers denote a road linking sites pip_i and qiq_i of length lil_i. You may assume that for each test case it is possible to travel from Bitingham to Byteburg and to each of the sites Byteasar wants to visit.

The (m+1)(m+1)-th line contains one integer gg (0gk(k1)/20 \le g \le k \cdot (k-1) / 2). It is the number of restrictions on the order in which Byteasar wants to visit the sites of his selection. These restrictions are given in the following gg lines, one per line. The (m+i+1)(m+i+1)-th line contains two integers rir_i and sis_i separated by a single space, with 2rik+12 \le r_i \le k+1, 2sik+12 \le s_i \le k+1, risir_i \ne s_i. The pair (ri,si)(r_i, s_i) means that Byteasar wants to visit site rir_i before visiting site sis_i. It does not, however, prevent him from passing through sis_i before visiting rir_i, nor from passing through rir_i after having visited sis_i; he is free to do so as long as he does not stop and visit the tourist attractions. It is guaranteed that for each test case at least one order of visiting the selected sites that satisfies all the restrictions exists.

Output

Output a single integer: the length of the shortest route from Bitingham to Byteburg that passes, in a proper order, through all the sites Byteasar has selected.