Problem1871--【CSP2021-S-T4】交通规划

1871: 【CSP2021-S-T4】交通规划

[Creator : ]
Time Limit : 3.000 sec  Memory Limit : 512 MB

Submit

Description

Input



Output

Sample Input Copy

2 3 1
9 4 7
3 8
10 5
2
19 3 1
17 9 0

Sample Output Copy

12

HINT



Source/Category

NOIP