#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll MOD = 1e+9 + 7;
vector<ll> dijkstra(vector<vector<pair<int, ll>>> &g, int start) {
  vector<ll> dist(g.size() + 1, LLONG_MAX);
  priority_queue<pair<ll, int>> q;
  q.push({0, start});
  dist[start] = 0;
  while (!q.empty()) {
    ll cost = -q.top().first;
    int node = q.top().second;
    q.pop();
    if (dist[node] < cost) continue;
    for (auto p : g[node])
      if (cost + p.second < dist[p.first]) {
        dist[p.first] = cost + p.second;
        q.push({-dist[p.first], p.first});
      }
  }
  return dist;
}
const int N = 1005;
int n, m, k;
vector<vector<pair<int, ll>>> g(N);
vector<pair<int, int>> routes(N);
vector<ll> first[N], second[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed;
  cout << setprecision(10);
  cin >> n >> m >> k;
  for (int i = 1; i <= m; i++) {
    int x, y;
    ll w;
    cin >> x >> y >> w;
    g[x].push_back({y, w});
    g[y].push_back({x, w});
  }
  for (int i = 1; i <= k; i++) cin >> routes[i].first >> routes[i].second;
  for (int i = 1; i <= k; i++) {
    first[i] = dijkstra(g, routes[i].first);
    second[i] = dijkstra(g, routes[i].second);
  }
  ll ans = 0;
  for (int i = 1; i <= k; i++) ans += first[i][routes[i].second];
  for (int i = 1; i <= n; i++) {
    for (auto p : g[i]) {
      int j = p.first;
      ll cur = 0;
      for (int r = 1; r <= k; r++)
        cur += min({first[r][i] + second[r][j], first[r][j] + second[r][i],
                    first[r][routes[r].second]});
      ans = min(ans, cur);
    }
  }
  cout << ans;
}
