#include <bits/stdc++.h>
using namespace std;
long long n, m, kk;
long long x[10000], y[10000], w[10000];
long long a[10000], b[10000];
long long mand[2000][2000];
vector<pair<long long, long long>> neig[10000];
void Dijkstra(long long n, const vector<pair<long long, long long>>* neig,
              long long v, long long* dist) {
  const long long INF = 1000000000000LL;
  set<pair<long long, long long>> dist_index_set;
  for (long long i = 0; i < n; i++) {
    dist[i] = (i == v ? 0 : INF);
    dist_index_set.insert(make_pair(dist[i], i));
  }
  long long tmp_dist;
  while (!dist_index_set.empty()) {
    pair<long long, long long> lowest_dist_pair = *(dist_index_set.begin());
    const long long lowest_dist = lowest_dist_pair.first;
    const long long closest_v = lowest_dist_pair.second;
    dist_index_set.erase(lowest_dist_pair);
    for (const auto [u, v_u_length] : neig[closest_v]) {
      tmp_dist = lowest_dist + v_u_length;
      if (tmp_dist >= dist[u]) {
        continue;
      }
      dist_index_set.erase(make_pair(dist[u], u));
      dist[u] = tmp_dist;
      dist_index_set.insert(make_pair(tmp_dist, u));
    }
  }
}
signed main() {
  cout.precision(15);
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> m >> kk;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      mand[i][j] = (i == j ? 0 : 1000000000);
    }
  }
  for (long long i = 0; i < m; i++) {
    cin >> x[i] >> y[i] >> w[i];
    x[i]--;
    y[i]--;
    if (mand[x[i]][y[i]] > w[i]) {
      mand[x[i]][y[i]] = mand[y[i]][x[i]] = w[i];
      neig[x[i]].push_back(make_pair(y[i], w[i]));
      neig[y[i]].push_back(make_pair(x[i], w[i]));
    }
  }
  for (long long i = 0; i < kk; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }
  for (long long i = 0; i < n; i++) {
    Dijkstra(n, neig, i, mand[i]);
  }
  long long pas = 1000000000000LL;
  for (long long i = 0; i < m; i++) {
    long long sum = 0;
    for (long long j = 0; j < kk; j++) {
      long long mnd = mand[a[j]][b[j]];
      long long tmp = mand[a[j]][x[i]] + mand[y[i]][b[j]];
      long long tmp1 = mand[a[j]][y[i]] + mand[x[i]][b[j]];
      if (tmp < mnd) mnd = tmp;
      if (tmp1 < mnd) mnd = tmp1;
      sum += mnd;
    }
    if (sum < pas) pas = sum;
  }
  cout << pas << endl;
  return 0;
}
