#include <bits/stdc++.h>
using namespace std;
long long arrival[1005], departure[1005], vis[1005], parent[1005];
vector<pair<long long, long long> > g[1005];
long long n, m, k;
long long dist[1005][1005];
void dijkstra(long long source) {
  for (long long i = 1; i < 1005; i++) {
    arrival[i] = 1e18;
    departure[i] = 1e18;
    vis[i] = 0;
  }
  arrival[source] = 0;
  set<pair<long long, long long> > s;
  s.insert({0, source});
  while (!s.empty()) {
    auto x = *(s.begin());
    s.erase(x);
    vis[x.second] = 1;
    departure[x.second] = arrival[x.second];
    for (auto it : g[x.second]) {
      if (arrival[it.first] > departure[x.second] + it.second) {
        s.erase({arrival[it.first], it.first});
        arrival[it.first] = departure[x.second] + it.second;
        s.insert({arrival[it.first], it.first});
        parent[it.first] = x.second;
      }
    }
  }
  for (long long i = 1; i < 1005; i++) dist[source][i] = departure[i];
}
void solve() {
  long long ans = LLONG_MAX;
  cin >> n >> m >> k;
  vector<pair<long long, long long> > edge, path(k);
  for (long long i = 1; i <= m; i++) {
    long long x, y, w;
    cin >> x >> y >> w;
    edge.push_back({x, y});
    g[x].push_back({y, w});
    g[y].push_back({x, w});
  }
  for (long long i = 0; i < k; i++) cin >> path[i].first >> path[i].second;
  for (long long i = 1; i <= n; i++) dijkstra(i);
  for (auto X : edge) {
    long long tt = 0;
    for (auto Y : path) {
      tt += min(dist[Y.first][Y.second],
                min(dist[Y.first][X.first] + dist[X.second][Y.second],
                    dist[Y.first][X.second] + dist[X.first][Y.second]));
    }
    ans = min(ans, tt);
  }
  cout << ans << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t = 1;
  while (t--) {
    solve();
  }
}
