#include <bits/stdc++.h>
using namespace std;
struct node {
  long long v, c;
  node(long long vv = 0, long long cc = 0) { v = vv, c = cc; }
  bool operator<(const node &a) const { return c > a.c; }
};
struct edge {
  long long v, cost;
  edge(long long vv = 0, long long ccost = 0) {
    v = vv;
    cost = ccost;
  }
};
bool vis[1005];
int dist[1005][1005];
vector<node> E[1005];
void addedge(int u, int v, int cost) { E[u].push_back(node(v, cost)); }
void dij(int n, int st) {
  for (int i = 0; i <= n; i++) {
    vis[i] = 0;
  }
  for (int i = 1; i <= n; i++) dist[st][i] = 1e9;
  priority_queue<node> q;
  while (!q.empty()) q.pop();
  dist[st][st] = 0;
  q.push(node(st, 0));
  while (!q.empty()) {
    node tmp = q.top();
    q.pop();
    int u = tmp.v;
    if (vis[u]) continue;
    vis[u] = true;
    int sz = E[u].size();
    for (int i = 0; i < sz; i++) {
      int v = E[tmp.v][i].v;
      int cost = E[u][i].c;
      if (!vis[v] && dist[st][v] > dist[st][u] + cost) {
        dist[st][v] = dist[st][u] + cost;
        q.push(node(v, dist[st][v]));
      }
    }
  }
}
int x[1005], y[1005];
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    addedge(u, v, w);
    addedge(v, u, w);
  }
  for (int i = 0; i < k; i++) cin >> x[i] >> y[i];
  for (int i = 1; i <= n; i++) dij(n, i);
  int ans = 1e9;
  for (int i = 1; i <= n; i++) {
    int sz = E[i].size();
    for (int j = 0; j < sz; j++) {
      int v = E[i][j].v;
      int tmp = 0;
      for (int ii = 0; ii < k; ii++) {
        if (x[ii] == y[ii]) continue;
        tmp += min(dist[x[ii]][y[ii]], min(dist[x[ii]][i] + dist[y[ii]][v],
                                           dist[x[ii]][v] + dist[y[ii]][i]));
      }
      ans = min(ans, tmp);
    }
  }
  cout << ans << '\n';
  return 0;
}
