## Algorithm

B. Jzzhu and Cities
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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 ui to vi (and vise versa) using the i-th road, the length of this road is xi. 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 si (and vise versa), the length of this route is yi.

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 ≤ 105; 1 ≤ m ≤ 3·105; 1 ≤ k ≤ 105).

Each of the next m lines contains three integers ui, vi, xi (1 ≤ ui, vi ≤ nui ≠ vi; 1 ≤ xi ≤ 109).

Each of the next k lines contains two integers si and yi (2 ≤ si ≤ n; 1 ≤ yi ≤ 109).

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.

Examples
input
Copy
`5 5 31 2 12 3 21 3 33 4 41 5 53 54 55 5`
output
Copy
`2`
input
Copy
`2 2 31 2 22 1 32 12 22 3`
output
Copy
`2`

## Code Examples

### #1 Code Example with C++ Programming

```Code - C++ Programming```

``````#include <stdio.h>
#include  <vector>
#include  <queue>
#include  <algorithm>

using namespace std;

int const N = 1e5 + 1;
int n, m, k, res;
long long cost[N];
bool vis[N];
vector <vector <pair <int, int> > > g;
priority_queue <pair <pair <long long, int>, bool> > q;

void Dijkstra(int src) {
fill(cost, cost + N, 1e18);
q.push(make_pair(make_pair(0, src), false));
cost[src] = 0;

while(!q.empty()) {
int v = q.top().first.second;
long long c = -q.top().first.first;
bool train = q.top().second;
q.pop();

if(cost[v]  <= c && train) {
++res;
continue;
} else if(cost[v] > c && train)
cost[v] = c;

if(vis[v])
continue;
vis[v] = true;

for(int i = 0, u; i  < (int)g[v].size(); ++i) {
u = g[v][i].first;
if(1LL * c + g[v][i].second  < cost[u]) {
cost[u] = 1LL * c + g[v][i].second;
q.push(make_pair(make_pair(-cost[u], u), false));
}
}
}
}

int main() {
scanf("%d %d %d", &n, &m, &k);
g.resize(n);

for(int i = 0, a, b, c; i  < m; ++i) {
scanf("%d %d %d", &a, &b, &c);
--a, --b;
g[a].push_back(make_pair(b, c));
g[b].push_back(make_pair(a, c));
}

for(int i = 0, a, c; i  < k; ++i) {
scanf("%d %d", &a, &c);
--a;
q.push(make_pair(make_pair(-c, a), true));
}

Dijkstra(0);

printf("%d\n", res);

return 0;
}``````
Copy The Code &

Input

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

Output

cmd
2