#include <bits/stdc++.h>
using namespace std;
inline int qr() {
  int f = 0, fu = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') fu = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    f = (f << 3) + (f << 1) + c - 48;
    c = getchar();
  }
  return f * fu;
}
const int N = 1005;
int head[N], ver[N << 1], Next[N << 1], edge[N << 1], tot;
int d[N][N], a[N][N];
bool v[N];
int n, m, k;
inline void add(int x, int y, int z) {
  ver[++tot] = y;
  edge[tot] = z;
  Next[tot] = head[x];
  head[x] = tot;
}
deque<int> q;
inline void spfa(int s) {
  memset(d[s], 0x3f, sizeof(int) * (n + 1));
  d[s][s] = 0, q.push_back(s), v[s] = true;
  while (!q.empty()) {
    int x = q.front();
    q.pop_front(), v[x] = false;
    for (register int i = head[x]; i; i = Next[i]) {
      int y = ver[i], z = edge[i];
      if (d[s][y] > d[s][x] + z) {
        d[s][y] = d[s][x] + z;
        if (!v[y]) {
          q.empty() || d[s][y] > d[s][q.front()] ? q.push_back(y)
                                                 : q.push_front(y);
          v[y] = true;
        }
      }
    }
  }
}
vector<pair<int, int> > e, tmp;
int ans = 0x3f3f3f3f;
bool vis[N];
int main() {
  n = qr(), m = qr(), k = qr();
  memset(a, 0x3f, sizeof(a));
  for (register int i = 1; i <= m; ++i) {
    int x = qr(), y = qr(), z = qr();
    if (x == y) continue;
    if (a[x][y] == 0x3f3f3f3f) tmp.push_back({x, y});
    a[x][y] = a[y][x] = min(a[x][y], z);
  }
  for (auto it : tmp) {
    add(it.first, it.second, a[it.first][it.second]);
    add(it.second, it.first, a[it.second][it.first]);
  }
  for (register int i = 1; i <= k; ++i) {
    int x = qr(), y = qr();
    e.push_back({x, y});
    if (!vis[x]) spfa(x), vis[x] = true;
    if (!vis[y]) spfa(y), vis[y] = true;
  }
  m = tmp.size();
  for (register int i = 0; i <= m - 1; ++i) {
    int sum = 0;
    for (register int j = 0; j <= k - 1; ++j)
      sum += min({d[e[j].first][e[j].second],
                  d[e[j].first][tmp[i].first] + d[e[j].second][tmp[i].second],
                  d[e[j].first][tmp[i].second] + d[e[j].second][tmp[i].first]});
    ans = min(ans, sum);
  }
  printf("%d\n", ans);
  return 0;
}
