Problem2974--CF449 - B. Jzzhu and Cities

2974: CF449 - B. Jzzhu and Cities

[Creator : ]
Time Limit : 2.000 sec  Memory Limit : 512 MiB

Description

Jzzhu is the president of country A. There are $n$ cities numbered from $1$ to $n$ in his country. City $1$ is the capital of A. Also there are $m$ roads connecting the cities. One can go from city $u_i$ to $v_i$ (and vise versa) using the $i$-th road, the length of this road is $x_i$. Finally, there are $k$ train routes in the country. One can use the $i$-th train route to go from capital of the country to city $s_i$ (and vise versa), the length of this route is $y_i$.
Jzzhu doesn't want to waste the money of the country, so he is going to close some of the train routes. Please tell Jzzhu the maximum number of the train routes which can be closed under the following condition: the length of the shortest path from every city to the capital mustn't change.

Input

The first line contains three integers $n,m,k\ (2 ≤n≤ 10^5;\ 1 ≤m≤ 3·10^5;\ 1 ≤k≤ 10^5)$.
Each of the next $m$ lines contains three integers $u_i,v_i,x_i\ (1 ≤u_i,v_i≤n;\ u_i≠v_i;\ 1 ≤x_i≤ 10^9)$.
Each of the next $k$ lines contains two integers $s_i, y_i\ (2 ≤s_i≤n;\ 1 ≤y_i≤ 10^9)$.
It is guaranteed that there is at least one way from every city to the capital. Note, that there can be multiple roads between two cities. Also, there can be multiple routes going to the same city from the capital.

Output

Output a single integer representing the maximum number of the train routes which can be closed.

Sample 1 Input

5 5 3
1 2 1
2 3 2
1 3 3
3 4 4
1 5 5
3 5
4 5
5 5

Sample 1 Output

2

Sample 2 Input

2 2 3
1 2 2
2 1 3
2 1
2 2
2 3

Sample 2 Output

2

HINT

CF449B.

Source/Category