#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
long long dp[1001][1001];
vector<pair<int, int> > g[1001];
int n;
void dijkastra(int v) {
  for (int i = 1; i <= n; ++i) dp[v][i] = INF;
  dp[v][v] = 0;
  set<pair<int, int> > s;
  s.insert({0, v});
  while (!s.empty()) {
    auto first_element_of_set = *(s.begin());
    int ind = first_element_of_set.second;
    s.erase(first_element_of_set);
    for (int i = 0; i < g[ind].size(); ++i) {
      int to = g[ind][i].first;
      int w = g[ind][i].second;
      if (dp[v][ind] + w < dp[v][to]) {
        s.erase({dp[v][to], to});
        dp[v][to] = w + dp[v][ind];
        s.insert({dp[v][to], to});
      }
    }
  }
}
int main() {
  int m, k;
  cin >> n >> m >> k;
  int in1[m + 10], to1[m + 10];
  for (int i = 1; i <= m; ++i) {
    int w;
    cin >> in1[i] >> to1[i] >> w;
    g[in1[i]].push_back({to1[i], w});
    g[to1[i]].push_back({in1[i], w});
  }
  for (int i = 1; i <= n; ++i) dijkastra(i);
  long long ans = 1e9, mx = 0;
  int in[k + 10], to[k + 10];
  for (int i = 1; i <= k; ++i) cin >> in[i] >> to[i];
  for (int i = 1; i <= m; ++i) {
    long long cnt = 0;
    for (int j = 1; j <= k; ++j)
      cnt += min({dp[in[j]][to[j]], dp[in[j]][in1[i]] + dp[to1[i]][to[j]],
                  dp[in[j]][to1[i]] + dp[in1[i]][to[j]]});
    ans = min(cnt, ans);
  }
  cout << ans;
  return 0;
}
