#include <bits/stdc++.h>
using namespace std;
int const N = 1010;
int const M = 10010;
struct Edges {
  int u, v, w, next;
} e[M];
int p[N], idx;
void init() {
  memset(p, (0xff), sizeof p);
  idx = 0;
}
void addedge(int u, int v, int w) {
  e[idx].u = v, e[idx].v = u, e[idx].w = w, e[idx].next = p[u], p[u] = idx++;
}
priority_queue<pair<int, int> > Q;
int dis[N];
bool vis[N];
void dijkstra(int s) {
  int u, v, w;
  while (!Q.empty()) Q.pop();
  memset(vis, (0), sizeof vis), memset(dis, (0x3f), sizeof dis);
  Q.push(make_pair(0, s)), dis[s] = 0;
  while (!Q.empty()) {
    pair<int, int> tmp = Q.top();
    Q.pop();
    if (vis[u = tmp.second])
      continue;
    else
      vis[u] = true;
    for (int i = p[u]; ~i; i = e[i].next) {
      v = e[i].u, w = e[i].w;
      if (!vis[v] && dis[u] + w < dis[v]) {
        dis[v] = dis[u] + w;
        Q.push(make_pair(-dis[v], v));
      }
    }
  }
}
int fr[N], de[N];
int d1[N][N], d2[N][N];
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  init();
  for (int i = 0; i < (m); ++i) {
    int x, y, w;
    scanf("%d%d%d", &x, &y, &w);
    addedge(x, y, w);
    addedge(y, x, w);
  }
  for (int i = 0; i < (k); ++i) {
    scanf("%d%d", &fr[i], &de[i]);
    dijkstra(fr[i]);
    for (int j = 1; j <= (n); ++j) d1[i][j] = dis[j];
    dijkstra(de[i]);
    for (int j = 1; j <= (n); ++j) d2[i][j] = dis[j];
  }
  int ans = 0x3f3f3f3f;
  for (int i = 0; i < (m); ++i) {
    int x = e[i * 2].u, y = e[i * 2].v;
    int s = 0;
    for (int j = 0; j < (k); ++j) {
      int t = min(d1[j][x] + d2[j][y], d1[j][y] + d2[j][x]);
      t = min(t, d1[j][de[j]]);
      s += t;
    }
    ans = min(ans, s);
  }
  printf("%d\n", ans);
  return 0;
}
