#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > edge[1010], cou, ed;
int dist[1010][1010];
struct cmp {
  bool operator()(const pair<int, int> &a, const pair<int, int> &b) const {
    return a.second > b.second;
  }
};
void dijikstra(int n) {
  for (int i = 0; i < 1010; i++) dist[n][i] = 1000000010;
  priority_queue<pair<int, int>, vector<pair<int, int> >, cmp> que;
  dist[n][n] = 0;
  que.push({n, 0});
  while (!que.empty()) {
    pair<int, int> u = que.top();
    que.pop();
    if (u.second != dist[n][u.first]) continue;
    for (auto v : edge[u.first]) {
      if (dist[n][v.first] > dist[n][u.first] + v.second) {
        dist[n][v.first] = dist[n][u.first] + v.second;
        que.push({v.first, dist[n][v.first]});
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  int i, j, k, a, b, c, x, y, z, n, w, m, t;
  cin >> n >> m >> k;
  for (i = 0; i < m; i++) {
    cin >> a >> b >> w;
    edge[a].push_back({b, w});
    edge[b].push_back({a, w});
    ed.push_back({a, b});
  }
  for (i = 0; i < k; i++) {
    cin >> a >> b;
    cou.push_back({a, b});
  }
  for (i = 1; i < n + 1; i++) {
    dijikstra(i);
  }
  int ans = 1e9 + 7;
  for (auto j : ed) {
    z = 0;
    for (auto i : cou) {
      z += min(dist[i.first][i.second],
               min(dist[i.first][j.first] + dist[j.second][i.second],
                   dist[i.first][j.second] + dist[j.first][i.second]));
    }
    ans = min(ans, z);
  }
  cout << ans << "\n";
}
