#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")
template <typename T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const long long MOD = 1000000007LL;
const long long MOD2 = 998244353LL;
const long double PI = acos(-1);
const int MAXN = 1001;
const int INF = 1e9 + 54;
vector<pair<int, int> > g[MAXN];
int dst[MAXN][MAXN];
void solve() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<pair<int, int> > e;
  for (int i = 0; i < m; i++) {
    int first, second, w;
    cin >> first >> second >> w;
    first--, second--;
    g[first].emplace_back(second, w);
    g[second].emplace_back(first, w);
    e.emplace_back(first, second);
  }
  memset(dst, 0x3f, sizeof dst);
  for (int i = 0; i < n; i++) {
    dst[i][i] = 0;
    set<pair<int, int> > q;
    q.insert(make_pair(0, i));
    while (!q.empty()) {
      int v = q.begin()->second;
      q.erase(q.begin());
      for (auto j : g[v]) {
        int u = j.first;
        int w = j.second;
        if (dst[i][u] > dst[i][v] + w) {
          q.erase(make_pair(dst[i][u], u));
          dst[i][u] = dst[i][v] + w;
          q.insert(make_pair(dst[i][u], u));
        }
      }
    }
  }
  int ans = INF;
  vector<pair<int, int> > rt(k);
  for (int i = 0; i < k; i++) {
    cin >> rt[i].first >> rt[i].second;
    rt[i].first--;
    rt[i].second--;
  }
  for (int i = 0; i < m; i++) {
    int res = 0;
    int first = e[i].first;
    int second = e[i].second;
    for (int j = 0; j < k; j++) {
      int a = rt[j].first, b = rt[j].second;
      res += min(dst[a][b], min(dst[a][first], dst[a][second]) +
                                min(dst[first][b], dst[second][b]));
    }
    ans = min(res, ans);
  }
  cout << ans << '\n';
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
