#include <bits/stdc++.h>
using namespace std;
vector<vector<long long> > stp;
vector<vector<pair<long long, long long> > > g;
vector<pair<long long, long long> > ord;
int n;
void dij(int x) {
  set<pair<long long, long long> > s;
  s.insert({0, x});
  while (!s.empty()) {
    pair<long long, long long> y = *s.begin();
    s.erase(s.begin());
    for (auto j : g[y.second]) {
      long long y1 = j.second, cost = j.first;
      if (stp[x][y.second] + cost < stp[x][y1]) {
        if (stp[x][y1] != INT_MAX) s.erase({stp[x][y1], y1});
        stp[x][y1] = stp[x][y.second] + cost;
        s.insert({stp[x][y1], y1});
      }
    }
  }
}
void fun() {
  int m, k;
  cin >> n >> m >> k;
  stp.assign(n, vector<long long>(n, LLONG_MAX));
  g.resize(n);
  for (int i = 0; i < n; i++) stp[i][i] = 0;
  for (int i = 0; i < m; i++) {
    long long x, y, z;
    cin >> x >> y >> z;
    x--;
    y--;
    g[x].push_back({z, y});
    g[y].push_back({z, x});
  }
  for (int i = 0; i < k; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    ord.push_back({x, y});
  }
  for (int i = 0; i < n; i++) dij(i);
  long long ans = LLONG_MAX;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < g[i].size(); j++) {
      long long tt = 0, r = g[i][j].second;
      for (int kk = 0; kk < k; kk++) {
        int d1 = ord[kk].first, d2 = ord[kk].second;
        tt += min(stp[d1][d2],
                  min(stp[d1][i] + stp[r][d2], stp[d1][r] + stp[i][d2]));
      }
      ans = min(ans, tt);
    }
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  srand(time(0));
  ;
  int t = 1;
  while (t--) {
    fun();
  }
}
