#include <bits/stdc++.h>
using namespace std;
long long n, m, k, peso[1010], a[1010], b[1010], dist[1010][1010], aux[1010];
vector<pair<long long, long long> > vertice[1010];
pair<long long, long long> ponta[1010], rota[1010];
void bfs(long long x, long long y) {
  for (long long i = 1; i <= n; i++) aux[i] = -1;
  aux[x] = 0;
  set<pair<long long, long long> > s;
  s.insert({0, x});
  while (s.size() != 0) {
    pair<long long, long long> u = *s.begin();
    s.erase(*s.begin());
    for (long long i = 0; i < vertice[u.second].size(); i++) {
      long long v = vertice[u.second][i].second,
                estrada = vertice[u.second][i].first;
      if (aux[v] == -1 or aux[v] > u.first + peso[estrada]) {
        aux[v] = u.first + peso[estrada];
        s.insert({aux[v], v});
      }
    }
  }
}
void solve() {
  cin >> n >> m >> k;
  for (long long i = 1; i <= m; i++) {
    long long x, y, w;
    cin >> x >> y >> w;
    vertice[x].push_back({i, y});
    vertice[y].push_back({i, x});
    peso[i] = w;
    ponta[i] = {x, y};
  }
  for (long long i = 1; i <= k; i++) cin >> a[i] >> b[i];
  for (long long i = 1; i <= k; i++) {
    bfs(a[i], b[i]);
    dist[a[i]][b[i]] = aux[b[i]];
    dist[b[i]][a[i]] = aux[b[i]];
  }
  long long resp = 9123456789;
  for (long long i = 1; i <= m; i++) {
    long long x = ponta[i].first, y = ponta[i].second, vez = 0, aux1[1010];
    bfs(y, x);
    for (long long j = 1; j <= n; j++) aux1[j] = aux[j];
    bfs(x, y);
    for (long long j = 1; j <= k; j++) {
      long long soma = dist[a[j]][b[j]];
      soma = min(soma, aux[a[j]] + aux1[b[j]]);
      soma = min(soma, aux1[a[j]] + aux[b[j]]);
      vez += soma;
    }
    resp = min(resp, vez);
  }
  cout << resp;
}
signed main() { solve(); }
