#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> g[1001];
int dist[1001][1001][2];
int n;
void dijkstra(int from, int freex, int freey, int ind) {
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      pq;
  for (int i = 1; i <= n; i++) {
    dist[from][i][ind] = 1e8;
  }
  dist[from][from][ind] = 0;
  pq.push({0, from});
  while (!pq.empty()) {
    pair<int, int> t = pq.top();
    pq.pop();
    for (pair<int, int> i : g[t.second]) {
      int cost = 0;
      if (!(i.first == freex && t.second == freey ||
            i.first == freey && t.second == freex)) {
        cost = i.second;
      }
      if (dist[from][t.second][ind] + cost < dist[from][i.first][ind]) {
        dist[from][i.first][ind] = dist[from][t.second][ind] + cost;
        pq.push({dist[from][i.first][ind], i.first});
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    int x, y, w;
    cin >> x >> y >> w;
    g[x].push_back({y, w});
    g[y].push_back({x, w});
  }
  for (int i = 1; i <= n; i++) {
    dijkstra(i, -1, -1, 0);
  }
  int cost = 0;
  vector<pair<int, int>> roads;
  for (int i = 0; i < k; i++) {
    int x, y;
    cin >> x >> y;
    roads.push_back({x, y});
    cost += dist[x][y][0];
  }
  int ans = cost;
  for (int i = 1; i <= n; i++) {
    for (pair<int, int> j : g[i]) {
      dijkstra(i, i, j.first, 1);
      int newcost = 0;
      for (pair<int, int> road : roads) {
        newcost += min(dist[road.first][road.second][0],
                       dist[i][road.first][1] + dist[i][road.second][1]);
      }
      ans = min(ans, newcost);
    }
  }
  cout << ans;
  return 0;
}
