#include <bits/stdc++.h>
using namespace std;
template <class T>
using pq = priority_queue<T>;
template <class T>
using pqg = priority_queue<T, vector<T>, greater<T>>;
template <class T>
bool ckmin(T& a, const T& b) {
  return b < a ? a = b, 1 : 0;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
template <class T>
void read(vector<T>& a, int n) {
  a.resize(n);
  for (int i = (0); i < (n); ++i) cin >> a[i];
}
template <class T>
void read(vector<vector<T>>& a, int n, int m) {
  a.resize(n, vector<T>(m));
  for (int i = (0); i < (n); ++i)
    for (int j = (0); j < (m); ++j) cin >> a[i][j];
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long MOD = 1e9 + 7;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
int n, m, k, u, v, w;
vector<vector<pair<int, int>>> adj;
vector<pair<int, int>> routes, edges;
vector<vector<int>> dist;
vector<bool> vis;
void solve() {
  cin >> n >> m >> k;
  adj.resize(n);
  dist.resize(n, vector<int>(n, 1e9));
  vis.resize(n, false);
  for (int i = (0); i < (m); ++i) {
    cin >> u >> v >> w;
    u--;
    v--;
    edges.push_back(make_pair(u, v));
    adj[u].push_back(make_pair(v, w));
    adj[v].push_back(make_pair(u, w));
  }
  for (int i = (0); i < (k); ++i) {
    cin >> u >> v;
    u--;
    v--;
    routes.push_back(make_pair(u, v));
  }
  for (int i = (0); i < (n); ++i) {
    pqg<pair<int, int>> pq;
    dist[i][i] = 0;
    fill(begin(vis), end(vis), false);
    pq.push(make_pair(0, i));
    while (!pq.empty()) {
      u = pq.top().second;
      pq.pop();
      if (vis[u]) continue;
      vis[u] = true;
      for (pair<int, int> nb : adj[u]) {
        if (!vis[nb.first] && dist[i][nb.first] > dist[i][u] + nb.second) {
          dist[i][nb.first] = dist[i][u] + nb.second;
          pq.push(make_pair(dist[i][nb.first], nb.first));
        }
      }
    }
  }
  long long ans = 1e18;
  for (pair<int, int> edge : edges) {
    u = edge.first;
    v = edge.second;
    long long cur = 0;
    for (pair<int, int> r : routes) {
      cur += min({dist[r.first][r.second], dist[r.first][u] + dist[v][r.second],
                  dist[r.first][v] + dist[u][r.second]});
    }
    ckmin(ans, cur);
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
}
