#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
const long long INF = (long long)2e19;
int n, m, k, tot;
long long d[N][N];
int x[N], y[N];
int a[N], b[N], v[N];
int ver[N << 1], edge[N << 1], nxt[N << 1], head[N];
void add(int x, int y, int z) {
  ver[++tot] = y;
  edge[tot] = z;
  nxt[tot] = head[x];
  head[x] = tot;
}
void dijkstra(int st) {
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      q;
  memset(v, 0, sizeof(v));
  for (int i = 1; i <= n; ++i) d[st][i] = INF;
  d[st][st] = 0;
  q.push(pair<int, int>(0, st));
  while (!q.empty()) {
    int x = q.top().second;
    q.pop();
    if (v[x]) continue;
    v[x] = 1;
    for (int i = head[x]; i; i = nxt[i]) {
      int y = ver[i];
      if (d[st][y] > d[st][x] + edge[i]) {
        d[st][y] = d[st][x] + (long long)edge[i];
        q.push(pair<int, int>(d[st][y], y));
      }
    }
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  int z;
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d%d", &x[i], &y[i], &z);
    add(x[i], y[i], z);
    add(y[i], x[i], z);
  }
  for (int i = 1; i <= n; ++i) {
    dijkstra(i);
  }
  for (int i = 1; i <= k; ++i) {
    scanf("%d%d", &a[i], &b[i]);
  }
  long long ans = INF;
  for (int i = 1; i <= m; ++i) {
    int u = x[i], v = y[i];
    long long res = 0;
    for (int j = 1; j <= k; ++j) {
      res += min(d[a[j]][b[j]],
                 min(d[a[j]][u] + d[b[j]][v], d[a[j]][v] + d[b[j]][u]));
    }
    ans = min(ans, res);
  }
  printf("%lld\n", ans);
  return 0;
}
