#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
vector<vector<pair<int, int>>> v;
int n;
void dijsktra(int s, vector<int> &d) {
  d = vector<int>(n, INF);
  d[s] = 0;
  set<pair<int, int>> st;
  st.insert({d[s], s});
  while (!st.empty()) {
    int t = st.begin()->second;
    st.erase(st.begin());
    for (auto &[to, w] : v[t]) {
      if (d[to] > (d[t] + w)) {
        auto it = st.find({d[to], to});
        if (it != st.end()) st.erase(it);
        d[to] = d[t] + w;
        st.insert({d[to], to});
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int m, k;
  cin >> n >> m >> k;
  v = vector<vector<pair<int, int>>>(n);
  for (int i = 0; i < m; ++i) {
    int x, y, w;
    cin >> x >> y >> w;
    --x;
    --y;
    v[x].push_back({y, w});
    v[y].push_back({x, w});
  }
  vector<pair<int, int>> r(k);
  for (auto &[a, b] : r) {
    cin >> a >> b;
    --a, --b;
  }
  vector<vector<int>> d(n);
  for (int v = 0; v < n; ++v) {
    dijsktra(v, d[v]);
  }
  int ans = INF;
  for (int t = 0; t < n; ++t) {
    for (auto &[to, w] : v[t]) {
      int cur = 0;
      for (auto &[a, b] : r) {
        cur += min({d[a][b], d[a][t] + d[to][b], d[a][to] + d[t][b]});
      }
      ans = min(cur, ans);
    }
  }
  cout << ans << endl;
}
