#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<int, int>>> graph(1000);
vector<pair<int, int>> edges;
vector<pair<int, int>> routes(1000);
vector<int> optcost(1000);
void dijkstra(int u) {
  int dist[1000];
  memset(dist, -1, sizeof(dist));
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      pq;
  pq.push({0, u});
  while (!pq.empty()) {
    pair<int, int> v = pq.top();
    pq.pop();
    if (dist[v.second] != -1) continue;
    dist[v.second] = v.first;
    for (auto x : graph[v.second]) {
      if (dist[x.first] != -1) continue;
      pq.push({v.first + x.second, x.first});
    }
  }
  for (int i = 0; i < routes.size(); i++) {
    if (routes[i].first == u)
      optcost[i] = dist[routes[i].second];
    else if (routes[i].second == u)
      optcost[i] = dist[routes[i].first];
  }
}
int dijkstra1(int u, int v) {
  int dist[1000];
  memset(dist, -1, sizeof(dist));
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      pq;
  pq.push({0, u});
  pq.push({0, v});
  while (!pq.empty()) {
    pair<int, int> v = pq.top();
    pq.pop();
    if (dist[v.second] != -1) continue;
    dist[v.second] = v.first;
    for (auto x : graph[v.second]) {
      if (dist[x.first] != -1) continue;
      pq.push({v.first + x.second, x.first});
    }
  }
  int minCost = 0;
  for (int i = 0; i < routes.size(); i++)
    minCost += min(optcost[i], dist[routes[i].first] + dist[routes[i].second]);
  return minCost;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    int x, y, w;
    cin >> x >> y >> w, x--, y--;
    graph[x].push_back({y, w});
    graph[y].push_back({x, w});
    edges.push_back({x, y});
  }
  for (int i = 0; i < k; i++) {
    int x, y;
    cin >> x >> y, x--, y--;
    routes[i] = {x, y};
  }
  for (int i = 0; i < n; i++) dijkstra(i);
  int ans = INT_MAX;
  for (int i = 0; i < m; i++)
    ans = min(ans, dijkstra1(edges[i].first, edges[i].second));
  cout << ans << endl;
}
