#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 11;
const int MAXN = 1e5 + 5;
const int LG = 20;
const int INF = 1e9;
using ll = long long int;
using ull = unsigned long long int;
const ll MOD2 = 998244353;
const ll MOD1 = 1e9 + 7LL;
ll *inv;
template <typename T>
T power(T a, T b, T mod = MOD1) {
  T r = 1LL;
  while (b) {
    if (b & 1LL) {
      r = (r * a) % mod;
    }
    a = (a * a) % mod;
    b >>= 1LL;
  }
  return r;
}
void inversions() {
  inv = new ll[maxn];
  inv[0] = 0;
  for (int i = 1; i < maxn; ++i) {
    inv[i] = power((ll)i, MOD1 - 2LL);
  }
}
template <typename T>
T gcd(T a, T b) {
  while (b) {
    T t = b % a;
    a = b;
    b = t;
  }
  return a;
}
using pii = pair<ll, int>;
const int N = 1002;
vector<pii> g[N];
vector<vector<ll>> wt(N, vector<ll>(N));
vector<ll> dijkstra(int source, int n) {
  vector<ll> dist(n + 1, LLONG_MAX);
  vector<bool> vis(n + 1, false);
  priority_queue<pii, vector<pii>, greater<pii>> q;
  q.push({0LL, source});
  dist[source] = 0LL;
  while (!q.empty()) {
    int u = q.top().second;
    q.pop();
    if (vis[u]) continue;
    vis[u] = true;
    for (pii p : g[u]) {
      int v = p.second;
      ll w = p.first;
      if (dist[u] + w < dist[v]) {
        dist[v] = dist[u] + w;
        q.push({dist[v], v});
      }
    }
  }
  return dist;
}
int main() {
  int n, m, k;
  scanf("%d", &n);
  scanf("%d", &m);
  scanf("%d", &k);
  vector<pair<int, int>> edges;
  for (int i = 0; i < m; ++i) {
    int x, y;
    ll w;
    scanf("%d", &x);
    scanf("%d", &y);
    scanf("%lld", &w);
    g[x].emplace_back(w, y);
    g[y].emplace_back(w, x);
    edges.emplace_back(x, y);
  }
  vector<pair<int, int>> p;
  for (int i = 0; i < k; ++i) {
    int a, b;
    scanf("%d", &a);
    scanf("%d", &b);
    if (a > b) swap(a, b);
    p.emplace_back(a, b);
  }
  ll answer = LLONG_MAX;
  vector<ll> D[n + 1];
  for (int i = 1; i <= n; ++i) {
    D[i] = dijkstra(i, n);
  }
  for (auto e : edges) {
    int u = e.first;
    int v = e.second;
    ll sub = 0;
    for (auto pp : p) {
      int a = pp.first;
      int b = pp.second;
      sub += min({D[a][b], D[a][u] + D[v][b], D[a][v] + D[u][b]});
    }
    answer = min(sub, answer);
  }
  printf("%lld", answer);
  return 0;
}
