#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9 + 7;
template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
  cout << "[";
  for (auto& i : v) cout << i << ", ";
  cout << "]"
       << "\n";
  return os;
}
template <typename K, typename V>
ostream& operator<<(ostream& os, pair<K, V> p) {
  os << "{" << p.first << ", " << p.second << "} ";
  return os;
}
const long long N = 1e3 + 5;
vector<pair<long long, long long>> g[N];
long long n, m, k;
long long a[N], b[N], cost[N][N], u[N], v[N], w[N];
void dij(long long source) {
  vector<long long> dis(n + 1, inf);
  dis[source] = 0;
  set<pair<long long, long long>> st;
  st.insert({0, source});
  while (!st.empty()) {
    long long u = st.begin()->second;
    st.erase(st.begin());
    for (auto i : g[u]) {
      long long v = i.first;
      long long cc = i.second;
      if (dis[u] + cc < dis[v]) {
        st.erase({dis[v], v});
        dis[v] = dis[u] + cc;
        st.insert({dis[v], v});
      }
    }
  }
  for (long long i = 1; i <= n; i++) cost[source][i] = dis[i];
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m >> k;
  for (long long i = 1; i <= m; i++) {
    cin >> u[i] >> v[i] >> w[i];
    g[u[i]].push_back({v[i], w[i]});
    g[v[i]].push_back({u[i], w[i]});
  }
  for (long long i = 1; i <= n; i++) dij(i);
  for (long long i = 1; i <= k; i++) cin >> a[i] >> b[i];
  long long ans = 1e9;
  for (long long i = 1; i <= m; i++) {
    long long temp = 0;
    for (long long j = 1; j <= k; j++) {
      temp += min({cost[u[i]][a[j]] + cost[v[i]][b[j]],
                   cost[v[i]][a[j]] + cost[u[i]][b[j]], cost[a[j]][b[j]]});
    }
    ans = min(ans, temp);
  }
  cout << ans << "\n";
}
