#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
int h[N], e[2 * N], ne[2 * N], w[2 * N], idx;
int dist[N][N];
int n, m, k;
bool st[N];
pair<int, int> q[N];
void add(int a, int b, int c) {
  e[idx] = b;
  ne[idx] = h[a];
  w[idx] = c;
  h[a] = idx++;
}
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>
    heap;
void dijkstra(int start, int dist[]) {
  memset(st, 0, sizeof st);
  dist[start] = 0;
  heap.push({0, start});
  while (heap.size()) {
    int t = heap.top().second;
    heap.pop();
    if (st[t]) continue;
    st[t] = 1;
    for (int i = h[t]; i != -1; i = ne[i]) {
      int j = e[i];
      if (dist[j] > dist[t] + w[i]) {
        dist[j] = dist[t] + w[i];
        heap.push({dist[j], j});
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie();
  cout.tie(0);
  int T = 1;
  while (T--) {
    memset(dist, 0x3f, sizeof dist);
    memset(h, -1, sizeof h);
    cin >> n >> m >> k;
    for (int i = 1; i <= m; i++) {
      int a, b, c;
      cin >> a >> b >> c;
      add(a, b, c), add(b, a, c);
    }
    for (int i = 1; i <= k; i++) cin >> q[i].first >> q[i].second;
    for (int i = 1; i <= n; i++) dijkstra(i, dist[i]);
    long long ans = 1e18;
    for (int i = 0; i < idx; i += 2) {
      int a = e[i], b = e[i ^ 1];
      long long now = 0;
      for (int j = 1; j <= k; j++) {
        int from = q[j].first, to = q[j].second;
        now +=
            min(min(dist[from][a] + dist[b][to], dist[from][b] + dist[a][to]),
                dist[from][to]);
      }
      ans = min(ans, now);
    }
    cout << ans << '\n';
  }
  return 0;
}
