#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e12;
vector<long long> Dijkstra(int N, int s,
                           vector<pair<long long, long long>> edges[]) {
  vector<long long> dist(N, INF);
  dist[s] = 0;
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
                 greater<pair<long long, long long>>>
      pq;
  pq.push({0, s});
  while (pq.size()) {
    auto p = pq.top();
    pq.pop();
    int i = p.second;
    long long d = p.first;
    if (d > dist[i]) continue;
    for (auto& e : edges[i]) {
      int j = e.first;
      long long d2 = d + e.second;
      if (d2 < dist[j]) {
        dist[j] = d2;
        pq.push({d2, j});
      }
    }
  }
  return dist;
}
int n, m, k;
vector<pair<long long, long long>> adj[1100];
vector<pair<long long, long long>> edges;
vector<long long> dist[1100];
vector<pair<long long, long long>> query;
void solve(int tc) {
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    adj[a].push_back({b, c});
    adj[b].push_back({a, c});
    edges.push_back({a, b});
  }
  for (int i = 0; i < n; i++) {
    dist[i] = Dijkstra(n, i, adj);
  }
  for (int i = 0; i < k; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    query.push_back({a, b});
  }
  long long ans = 1e12;
  for (pair<long long, long long> e : edges) {
    long long tmp = 0;
    for (int j = 0; j < k; j++) {
      tmp +=
          min({dist[query[j].first][e.first] + dist[e.second][query[j].second],
               dist[query[j].first][e.second] + dist[e.first][query[j].second],
               dist[query[j].first][query[j].second]});
    }
    ans = min(ans, tmp);
  }
  cout << ans << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  if (0) {
    int T;
    cin >> T;
    for (int i = 1; i <= T; i++) solve(i);
  } else {
    solve(0);
  }
  return 0;
}
