#include <bits/stdc++.h>
using namespace std;
int n, m, k;
const int N = 1e3 + 10;
int dis[N][N];
struct Edge {
  int to, next, w;
} E[N << 1];
int head[N], tot;
void addEdge(int from, int to, int w) {
  E[tot] = {to, head[from], w};
  head[from] = tot++;
  E[tot] = {from, head[to], w};
  head[to] = tot++;
}
int vis[N];
struct node {
  int id, d;
  bool operator<(const node& b) const { return d > b.d; }
};
void Dijkstra(int s) {
  priority_queue<node> Q;
  for (int i = 1; i <= n; i++) vis[i] = 0, dis[s][i] = 0x3f3f3f3f;
  Q.push({s, 0});
  dis[s][s] = 0;
  while (not Q.empty()) {
    int u = Q.top().id;
    Q.pop();
    if (vis[u]) continue;
    vis[u] = 1;
    for (int i = head[u]; ~i; i = E[i].next) {
      int v = E[i].to;
      if (not vis[v] and dis[s][v] > dis[s][u] + E[i].w) {
        dis[s][v] = dis[s][u] + E[i].w;
        Q.push({v, dis[s][v]});
      }
    }
  }
}
int x[N], y[N];
int u[N], v[N];
int main() {
  memset(head, -1, sizeof head);
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= m; i++) {
    int f, t, w;
    scanf("%d%d%d", &f, &t, &w);
    addEdge(f, t, w);
    x[i] = f, y[i] = t;
  }
  for (int i = 1; i <= n; i++) Dijkstra(i);
  for (int i = 1; i <= k; i++) scanf("%d%d", u + i, v + i);
  long long ans = 1e18;
  for (int i = 1; i <= m; i++) {
    long long sum = 0;
    for (int j = 1; j <= k; j++) {
      sum += min({dis[u[j]][v[j]], dis[u[j]][x[i]] + dis[y[i]][v[j]],
                  dis[v[j]][x[i]] + dis[y[i]][u[j]]});
    }
    ans = min(ans, sum);
  }
  printf("%lld\n", ans);
}
