#include <bits/stdc++.h>
using namespace std;
int h[1050], to[1000500], nex[1000500], w[1000500], cnt;
int passBy[1050][1050], d[1050][1050], ls[1050][1050];
bool vis[1050];
int n, m, t, st[1050], ed[1050], val[1050][1050];
int ex[1000500], ey[1000500], ez[1000500];
struct Node {
  int d, x;
  Node(int _d, int _x) : d(_d), x(_x) {}
  bool operator<(const Node& rhs) const { return d > rhs.d; }
};
inline void add(int u, int v, int t) {
  to[++cnt] = v;
  nex[cnt] = h[u];
  w[cnt] = t;
  h[u] = cnt;
}
inline void dij(int s) {
  memset(vis, 0, sizeof vis);
  priority_queue<Node> q;
  q.push(Node(0, s));
  d[s][s] = 0;
  while (!q.empty()) {
    auto tp = q.top();
    q.pop();
    if (vis[tp.x]) continue;
    vis[tp.x] = true;
    for (int e = h[tp.x]; e; e = nex[e]) {
      int v = to[e];
      if (d[s][v] > d[s][tp.x] + w[e]) {
        d[s][v] = d[s][tp.x] + w[e];
        q.push(Node(d[s][v], v));
      }
    }
  }
}
int main() {
  cin >> n >> m >> t;
  for (int i = 1; i <= m; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    val[x][y] = val[y][x] = z;
    ex[i] = x;
    ey[i] = y;
    ez[i] = z;
    add(x, y, z);
    add(y, x, z);
  }
  for (int i = 1; i <= t; i++) cin >> st[i] >> ed[i];
  memset(d, 0x3f3f3f3f, sizeof d);
  long long ans = 0x3f3f3f3f;
  for (int i = 1; i <= n; i++) dij(i);
  for (int i = 1; i <= m; i++) {
    long long tmp = 0;
    for (int j = 1; j <= t; j++) {
      tmp += min(d[st[j]][ed[j]], min(d[st[j]][ex[i]] + d[ey[i]][ed[j]],
                                      d[st[j]][ey[i]] + d[ex[i]][ed[j]]));
    }
    ans = min(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}
