#include <bits/stdc++.h>
using namespace std;
long long a, b, c, o, h[10001];
bool v[10001];
long long q, w, e;
long long qq[10001], ww[10001];
long long m[1001][1001], ans1;
struct p {
  long long q, w, e;
} l[10001];
struct pp {
  long long q, w;
  bool operator<(const pp &x) const { return w > x.w; }
};
priority_queue<pp> qu;
void diji(long long s) {
  memset(v, 0, sizeof(v));
  m[s][s] = 0;
  qu.push(pp{s, 0});
  while (!qu.empty()) {
    pp r = qu.top();
    qu.pop();
    if (v[r.q]) continue;
    v[r.q] = 1;
    for (int i = h[r.q]; i; i = l[i].w) {
      if (m[s][l[i].q] > m[s][r.q] + l[i].e) {
        m[s][l[i].q] = m[s][r.q] + l[i].e;
        qu.push(pp{l[i].q, m[s][l[i].q]});
      }
    }
  }
}
int main() {
  scanf("%lld%lld%lld", &a, &b, &c);
  for (int i = 1; i <= b; i++) {
    scanf("%lld%lld%lld", &q, &w, &e);
    o++;
    l[o].q = w;
    l[o].w = h[q];
    l[o].e = e;
    h[q] = o;
    o++;
    l[o].q = q;
    l[o].w = h[w];
    l[o].e = e;
    h[w] = o;
  }
  memset(m, 0x3f3f3f3f, sizeof(m));
  for (int i = 1; i <= a; i++) {
    diji(i);
  }
  for (int i = 1; i <= c; i++) {
    scanf("%lld%lld", &qq[i], &ww[i]);
    ans1 += m[qq[i]][ww[i]];
  }
  for (int i = 1; i <= a; i++) {
    for (int j = h[i]; j; j = l[j].w) {
      long long ans = 0;
      for (int k = 1; k <= c; k++) {
        ans += min(m[qq[k]][ww[k]], min(m[qq[k]][i] + m[l[j].q][ww[k]],
                                        m[qq[k]][l[j].q] + m[i][ww[k]]));
      }
      ans1 = min(ans1, ans);
    }
  }
  printf("%lld", ans1);
  return 0;
}
