#include <bits/stdc++.h>
using namespace std;
const int maxl = 1010;
const int inf = 1e9 + 10;
int n, m, k, cnt, tot, cas, ans;
int f[maxl][maxl];
struct edge {
  int u, v, w;
} edg[maxl * maxl];
struct ed {
  int v, l;
};
struct route {
  int a, b;
} a[maxl];
vector<ed> e[maxl];
bool vis[maxl][maxl];
char s[maxl];
inline void prework() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) f[i][j] = inf;
  for (int i = 1; i <= n; i++) f[i][i] = 0;
  int u, v, w;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &u, &v, &w);
    edg[i] = edge{u, v, w};
    f[u][v] = f[v][u] = min(f[u][v], w);
  }
  for (register int k = 1; k <= n; ++k)
    for (register int i = 1; i <= n; ++i)
      if (k != i)
        for (register int j = 1; j <= n; ++j)
          if (j != i && k != j) f[i][j] = min(f[i][j], f[i][k] + f[k][j]);
  for (int i = 1; i <= k; i++) scanf("%d%d", &a[i].a, &a[i].b);
}
inline void mainwork() {
  int u, v, tmp;
  ans = inf;
  for (register int i = 1; i <= m; ++i) {
    u = edg[i].u;
    v = edg[i].v;
    tmp = 0;
    for (register int j = 1; j <= k; ++j)
      tmp += min(f[a[j].a][a[j].b],
                 min(f[a[j].a][u] + f[a[j].b][v], f[a[j].a][v] + f[a[j].b][u]));
    ans = min(ans, tmp);
  }
}
inline void print() { printf("%d", ans); }
int main() {
  int t = 1;
  for (cas = 1; cas <= t; cas++) {
    prework();
    mainwork();
    print();
  }
  return 0;
}
