#include <bits/stdc++.h>
using namespace std;
const int INF = 1e8;
const long long IN = 1e18;
int n, m, k;
vector<vector<int>> adj, edge, dist;
int other(int e, int cur) {
  if (edge[e][0] == cur) return edge[e][1];
  return edge[e][0];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> k;
  adj = vector<vector<int>>(n);
  edge = vector<vector<int>>(m, vector<int>(3));
  dist = vector<vector<int>>(n, vector<int>(n, INF));
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < 3; j++) cin >> edge[i][j];
    edge[i][0]--;
    edge[i][1]--;
    adj[edge[i][0]].push_back(i);
    adj[edge[i][1]].push_back(i);
  }
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      pq;
  for (int i = 0; i < n; i++) {
    vector<bool> vis(n);
    pq.push({0, i});
    dist[i][i] = 0;
    while (!pq.empty()) {
      int cur = pq.top().second;
      pq.pop();
      if (vis[cur]) continue;
      vis[cur] = 1;
      for (int e : adj[cur]) {
        int x = other(e, cur);
        if (vis[x] || dist[i][x] <= dist[i][cur] + edge[e][2]) continue;
        dist[i][x] = dist[i][cur] + edge[e][2];
        pq.push({dist[i][x], x});
      }
    }
  }
  long long res = IN;
  vector<pair<int, int>> qry(k);
  for (int i = 0; i < k; i++) {
    cin >> qry[i].first >> qry[i].second;
    --qry[i].first;
    --qry[i].second;
  }
  for (int e = 0; e < m; e++) {
    long long cur = 0;
    for (int i = 0; i < k; i++) {
      int x = qry[i].first;
      int y = qry[i].second;
      cur += min({dist[x][y], dist[x][edge[e][0]] + dist[edge[e][1]][y],
                  dist[x][edge[e][1]] + dist[edge[e][0]][y]});
    }
    res = min(res, cur);
  }
  cout << res << '\n';
}
