F. Chinese Innovation
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

China has been unified, ending the Warring States Period and ushering in an era of innovations, such as teleportation. To connect the empire, the emperor has installed teleporters in various cities.

The empire consists of $$$n$$$ cities connected by $$$m$$$ roads, such that it is always possible to travel between any two cities using only these roads. Each road allows for bidirectional traffic and has a fixed travel cost.

Additionally, there are $$$k$$$ different types of teleporters. Two cities can connect instantly via teleportation only if both have a teleporter of the same type. However, the cost of using a teleporter depends on the city of origin, as each mayor sets the fee to be paid for leaving the city using the magical device. That is, even for the same type of teleporter, the usage cost can vary between cities.

The Japanese traveler Mori, upon arriving in China, does not understand its complex structure and is unable to determine the best routes for travel. He wishes to travel from city $$$1$$$ to city $$$n$$$. What is the minimum possible cost to make this journey, considering both the available roads and teleporters?

Input

The first line of input contains three integers: $$$n$$$, $$$m$$$, and $$$k$$$, representing the number of cities, the number of roads, and the number of distinct teleporter types, respectively. The values adhere to the constraints $$$2 \leq n \leq 2 \cdot 10^5$$$, $$$n - 1 \leq m \leq \min\left(\frac{n(n - 1)}{2}, 2 \cdot 10^5\right)$$$, and $$$0 \leq k \leq 2 \cdot 10^5$$$.

Each of the next $$$m$$$ lines describes an existing road between two cities. Each line contains three integers $$$u$$$, $$$v$$$, and $$$c$$$, indicating that there is a bidirectional road connecting cities $$$u$$$ and $$$v$$$ with a cost of $$$c$$$, where $$$1 \leq u, v \leq n$$$ and $$$1 \leq c \leq 10^9$$$. It is guaranteed that there is at least one path between any two cities using only roads, that there are no two distinct roads connecting the same pair of cities, and that no road connects a city to itself.

Next, for each of the $$$n$$$ cities, there is a line containing an integer $$$t$$$, indicating the number of teleporters available in that city, with $$$0 \leq t \leq 2 \cdot 10^5$$$. This line is followed by $$$t$$$ pairs of integers $$$(u_i, c_i)$$$, representing that a teleporter of type $$$u_i$$$ is available in the city, and the cost to use it from this city is $$$c_i$$$, where $$$1 \leq u_i \leq k$$$ and $$$1 \leq c_i \leq 10^9$$$. A single teleporter type may not exist in any city, exist in only one, or exist in multiple cities.

It is guaranteed that the same teleporter type does not appear twice in the same city and that the total sum of available teleporters across all cities does not exceed $$$\min(nk, 2 \cdot 10^5)$$$.

Output

Print a single integer representing the minimum cost to travel between cities $$$1$$$ and $$$n$$$.

Examples
Input
3 2 1
1 2 5
2 3 3
1
1 4
0
1
1 3
Output
4
Input
6 7 2
1 2 1
2 3 3
1 3 5
2 4 2
3 5 2
5 6 7
4 6 5
1
1 7
2
1 5
2 1
0
0
0
1
1 100
Output
6