#include <bits/stdc++.h>
using namespace std;
bitset<1002> vis;
const long long int oo = LLONG_MAX;
long long int dis[1002];
long long int n, m, k;
set<pair<long long int, long long int>> v[1002];
pair<long long int, long long int> arr[1002];
void dijkstra(int a) {
  priority_queue<pair<long long int, long long int>,
                 vector<pair<long long int, long long int>>,
                 greater<pair<long long int, long long int>>>
      pq;
  for (int i = 1; i <= n; i++) dis[i] = oo, vis[i] = 0;
  dis[a] = 0;
  pq.push({0, a});
  while (!pq.empty()) {
    long long int u, du, w, node;
    u = pq.top().second;
    du = pq.top().first;
    pq.pop();
    if (vis[u]) continue;
    vis[u] = 1;
    for (auto i : v[u]) {
      node = i.second;
      w = i.first;
      if (du + w < dis[node]) {
        dis[node] = du + w;
        pq.push({dis[node], node});
      }
    }
  }
}
long long int fck[1002];
void init_distances() {
  for (int i = 1; i <= k; i++) {
    int node = arr[i].first;
    dijkstra(node);
    fck[i] = dis[arr[i].second];
  }
}
pair<long long int, long long int> edges[1002];
long long int weight[1002];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> k;
  for (int i = 1; i <= m; i++) {
    long long int a, b;
    long long int w;
    cin >> a >> b >> w;
    weight[i] = w;
    if (a > b) swap(a, b);
    edges[i].first = a;
    edges[i].second = b;
    v[a].insert({w, b});
    v[b].insert({w, a});
  }
  for (int i = 1; i <= k; i++) cin >> arr[i].first >> arr[i].second;
  long long int temp[1002];
  init_distances();
  long long int fin = LLONG_MAX;
  for (int i = 1; i <= m; i++) {
    long long int a, b, w;
    a = edges[i].first;
    b = edges[i].second;
    w = weight[i];
    v[a].erase({w, b});
    v[b].erase({w, a});
    v[a].insert({0, b});
    v[b].insert({0, a});
    dijkstra(a);
    for (int j = 1; j <= n; j++) temp[j] = dis[j];
    dijkstra(b);
    long long int ans = 0;
    for (int j = 1; j <= k; j++) {
      long long int val = temp[arr[j].first] + dis[arr[j].second];
      long long int val1 = temp[arr[j].second] + dis[arr[j].first];
      val = min(val, val1);
      ans += min(val, fck[j]);
    }
    fin = min(fin, ans);
    v[a].erase({0, b});
    v[b].erase({0, a});
    v[a].insert({w, b});
    v[b].insert({w, a});
  }
  cout << fin << '\n';
}
