#include <bits/stdc++.h>
using namespace std;
long long int dp[1005][1005];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  for (long long int i = 0; i < 1005; i++) {
    for (long long int j = 0; j < 1005; j++) dp[i][j] = 1e9;
    dp[i][i] = 0;
  }
  long long int n, m, t;
  cin >> n >> m >> t;
  vector<pair<long long int, long long int> > v, v1;
  for (long long int i = 0; i < m; i++) {
    long long int x, y, z;
    cin >> x >> y >> z;
    dp[x][y] = min(z, dp[x][y]);
    dp[y][x] = min(z, dp[y][x]);
    v.push_back({x, y});
  }
  for (long long int k = 1; k <= n; k++) {
    for (long long int i = 1; i <= n; i++) {
      for (long long int j = 1; j <= n; j++) {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
      }
    }
  }
  long long int ans = 1e18;
  for (long long int i = 0; i < t; i++) {
    long long int x, y;
    cin >> x >> y;
    v1.push_back({x, y});
  }
  for (long long int i = 0; i < m; i++) {
    long long int cnt = 0;
    for (long long int j = 0; j < t; j++) {
      long long int u = v1[j].first, to = v1[j].second;
      cnt += min(dp[u][to], min(dp[u][v[i].first] + dp[v[i].second][to],
                                dp[u][v[i].second] + dp[v[i].first][to]));
    }
    ans = min(ans, cnt);
  }
  cout << ans;
}
