#include <bits/stdc++.h>
using namespace std;
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  long long f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
long long n, m, k;
vector<pair<long long, long long>> adj[1005];
long long dis[1005][1005];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m >> k;
  vector<pair<long long, long long>> edge;
  for (long long i = 0; i < m; i++) {
    long long u, v, w;
    cin >> u >> v >> w;
    adj[u].push_back({v, w});
    adj[v].push_back({u, w});
    edge.push_back({u, v});
  }
  vector<pair<long long, long long>> routes;
  for (long long i = 0; i < k; i++) {
    long long u, v;
    cin >> u >> v;
    routes.push_back({u, v});
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= n; j++) {
      dis[i][j] = 1000000005LL;
    }
    dis[i][i] = 0;
    priority_queue<pair<long long, long long>,
                   vector<pair<long long, long long>>,
                   greater<pair<long long, long long>>>
        st;
    st.push({0, i});
    while (!st.empty()) {
      long long v = (st.top()).second;
      st.pop();
      for (auto c : adj[v]) {
        long long to = c.first;
        long long len = c.second;
        if (dis[i][to] > dis[i][v] + len) {
          dis[i][to] = dis[i][v] + len;
          st.push({dis[i][to], to});
        }
      }
    }
  }
  long long ans = 0;
  for (auto i : routes) ans += dis[i.first][i.second];
  for (auto i : edge) {
    long long u = i.first, v = i.second, temp = 0;
    for (auto j : routes) {
      temp += min({dis[j.first][j.second], dis[j.first][u] + dis[j.second][v],
                   dis[j.first][v] + dis[j.second][u]});
    }
    ans = min(ans, temp);
  }
  cout << ans << "\n";
}
