#include <bits/stdc++.h>
using namespace std;
inline long long add(long long a, long long b) {
  return ((a % 1000000007LL) + (b % 1000000007LL)) % 1000000007LL;
}
inline long long mul(long long a, long long b) {
  return ((a % 1000000007LL) * (b % 1000000007LL)) % 1000000007LL;
}
inline long long sub(long long a, long long b) {
  return ((a % 1000000007LL) - (b % 1000000007LL) + 1000000007LL) %
         1000000007LL;
}
void Flash() {
  long long n, m, k;
  cin >> n >> m >> k;
  long long weight[n + 1][n + 1], count[n + 1][n + 1];
  memset(count, 0, sizeof(count));
  long long x[m], y[m], w[m];
  vector<long long> adj[n + 1];
  for (long long i = 0; i < m; i++) {
    cin >> x[i] >> y[i] >> w[i];
    adj[x[i]].push_back(y[i]);
    adj[y[i]].push_back(x[i]);
    weight[x[i]][y[i]] = w[i], weight[y[i]][x[i]] = w[i];
  }
  long long totalSum = 0;
  bool vis[n + 1];
  long long parent[n + 1];
  long long dist[n + 1][n + 1];
  set<pair<long long, long long> > qq;
  long long a, b;
  long long aa[k], bb[k];
  pair<long long, long long> temp;
  for (long long i = 0; i < k; i++) {
    cin >> a >> b;
    aa[i] = a, bb[i] = b;
    qq.clear();
    memset(parent, 0, sizeof(parent));
    memset(vis, false, sizeof(vis));
    for (long long i = 1; i <= n; i++) {
      dist[a][i] = 7000000000000000000LL;
    }
    dist[a][a] = 0;
    qq.insert({dist[a][a], a});
    while (!qq.empty()) {
      temp = (*qq.begin());
      qq.erase(qq.begin());
      vis[temp.second] = true;
      for (long long it : adj[temp.second]) {
        if (vis[it]) {
          continue;
        }
        if (dist[a][it] > (dist[a][temp.second] + weight[temp.second][it])) {
          qq.erase({dist[a][it], it});
          dist[a][it] = (dist[a][temp.second] + weight[temp.second][it]);
          parent[it] = temp.second;
          qq.insert({dist[a][it], it});
        }
      }
    }
    qq.clear();
    memset(parent, 0, sizeof(parent));
    memset(vis, false, sizeof(vis));
    for (long long i = 1; i <= n; i++) {
      dist[b][i] = 7000000000000000000LL;
    }
    dist[b][b] = 0;
    qq.insert({dist[b][b], b});
    while (!qq.empty()) {
      temp = (*qq.begin());
      qq.erase(qq.begin());
      vis[temp.second] = true;
      for (long long it : adj[temp.second]) {
        if (vis[it]) {
          continue;
        }
        if (dist[b][it] > (dist[b][temp.second] + weight[temp.second][it])) {
          qq.erase({dist[b][it], it});
          dist[b][it] = (dist[b][temp.second] + weight[temp.second][it]);
          parent[it] = temp.second;
          qq.insert({dist[b][it], it});
        }
      }
    }
  }
  long long ans = 7000000000000000000LL;
  long long tempAns = 0;
  for (long long i = 0; i < m; i++) {
    tempAns = 0;
    for (long long j = 0; j < k; j++) {
      tempAns += min({dist[aa[j]][bb[j]], dist[aa[j]][x[i]] + dist[bb[j]][y[i]],
                      dist[aa[j]][y[i]] + dist[bb[j]][x[i]]});
    }
    ans = min(ans, tempAns);
  }
  cout << ans << "\n";
}
int main(int argc, char const *argv[]) {
  ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
  ;
  long long t = 1;
  for (long long i = 1; i <= t; i++) {
    Flash();
  }
  return 0;
}
