#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
const int INF = 1e8;
int fx[maxn];
int fy[maxn];
struct edge {
  int to, w;
  edge(int _t = 0, int _w = 0) : to(_t), w(_w) {}
};
vector<edge> e[maxn];
int dis[maxn][maxn];
struct node {
  int u, d;
  node(int _u = 0, int _d = 0) : u(_u), d(_d) {}
  bool operator<(const node &b) const { return d > b.d; }
};
int a[maxn];
int b[maxn];
int Min[maxn];
int tmin[maxn];
void solve(int s, int n) {
  for (int i = 0; i <= n; i++) dis[s][i] = INF;
  dis[s][s] = 0;
  priority_queue<node> q;
  q.push(node(s, 0));
  while (!q.empty()) {
    node P = q.top();
    q.pop();
    int u = P.u;
    int d = P.d;
    if (dis[s][u] < d) continue;
    for (edge EE : e[u]) {
      int v = EE.to;
      int w = EE.w;
      if (dis[s][v] > d + w) {
        dis[s][v] = d + w;
        q.push(node(v, dis[s][v]));
      }
    }
  }
}
int main(void) {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= m; i++) {
    int x, y, w;
    scanf("%d%d%d", &x, &y, &w);
    e[x].push_back(edge(y, w));
    e[y].push_back(edge(x, w));
    fx[i] = x;
    fy[i] = y;
  }
  for (int i = 1; i <= k; i++) scanf("%d%d", &a[i], &b[i]);
  for (int i = 1; i <= n; i++) solve(i, n);
  for (int i = 1; i <= k; i++) Min[i] = dis[a[i]][b[i]];
  long long res = 0;
  for (int i = 1; i <= k; i++) res += Min[i];
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= k; j++) tmin[j] = Min[j];
    for (int j = 1; j <= k; j++) {
      tmin[j] = min(tmin[j], dis[a[j]][fx[i]] + dis[fy[i]][b[j]]);
      tmin[j] = min(tmin[j], dis[a[j]][fy[i]] + dis[fx[i]][b[j]]);
    }
    long long tmp = 0;
    for (int j = 1; j <= k; j++) tmp += tmin[j];
    res = min(res, tmp);
  }
  printf("%I64d\n", res);
  return 0;
}
