#include <bits/stdc++.h>
using namespace std;
const long long max_n = 1100;
const long long inf = 1e18 + 10;
long long n, m, k;
vector<pair<long long, long long>> adj[max_n];
long long dist[max_n][max_n];
void dij(long long s) {
  bool visited[n];
  memset(visited, 0, sizeof(visited));
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
                 greater<pair<long long, long long>>>
      p;
  dist[s][s] = 0;
  p.push({0, s});
  while (p.size() > 0) {
    long long c = p.top().second;
    p.pop();
    if (visited[c]) continue;
    visited[c] = 1;
    for (pair<long long, long long> x : adj[c])
      if (!visited[x.first]) {
        if (dist[s][c] + x.second < dist[s][x.first]) {
          dist[s][x.first] = dist[s][c] + x.second;
          p.push({dist[s][x.first], x.first});
        }
      }
  }
  return;
}
void fill() {
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      dist[i][j] = inf;
    }
  }
  for (long long i = 0; i < n; i++) dij(i);
  return;
}
vector<pair<long long, long long>> edges;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m >> k;
  for (long long i = 0; i < m; i++) {
    long long x, y, w;
    cin >> x >> y >> w;
    x--;
    y--;
    adj[x].push_back({y, w});
    adj[y].push_back({x, w});
    edges.push_back({x, y});
  }
  fill();
  pair<long long, long long> imp[k];
  long long ans = 0;
  for (long long i = 0; i < k; i++) {
    cin >> imp[i].first >> imp[i].second;
    imp[i].first--;
    imp[i].second--;
    ans += dist[imp[i].first][imp[i].second];
  }
  for (pair<long long, long long> e : edges) {
    long long current = 0;
    for (long long i = 0; i < k; i++) {
      long long c =
          min(dist[imp[i].first][imp[i].second],
              dist[imp[i].first][e.first] + dist[e.second][imp[i].second]);
      c = min(c, dist[imp[i].first][e.second] + dist[e.first][imp[i].second]);
      current += c;
    }
    ans = min(ans, current);
  }
  cout << ans << "\n";
}
