#include <bits/stdc++.h>
using namespace std;
const int maxn = 1024;
const long long inf = 1e18;
void fast_io() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
struct edge {
  int to, len;
  edge() {
    to = 0;
    len = 0;
  }
  edge(int _to, int _len) {
    to = _to;
    len = _len;
  }
  bool operator<(const edge &e) const { return len > e.len; }
};
vector<edge> v[maxn];
pair<int, int> r[maxn], p[maxn];
int n, m, k, used[maxn];
long long d[maxn][maxn];
void dijkstra(int s) {
  for (int i = 1; i <= n; i++) d[s][i] = inf;
  for (int i = 1; i <= n; i++) used[i] = 0;
  priority_queue<edge> q;
  q.push({s, 0});
  d[s][s] = 0;
  while (!q.empty()) {
    edge cur = q.top();
    q.pop();
    if (cur.len <= d[s][cur.to])
      if (!used[cur.to]) {
        int sz = v[cur.to].size();
        for (int i = 0; i < sz; i++) {
          edge nb = v[cur.to][i];
          if (cur.len + nb.len < d[s][nb.to]) {
            nb.len += cur.len;
            d[s][nb.to] = nb.len;
            q.push(nb);
          }
        }
      }
  }
}
void solve() {
  cin >> n >> m >> k;
  for (int i = 1; i <= m; i++) {
    int x, y, w;
    cin >> x >> y >> w;
    v[x].push_back({y, w});
    v[y].push_back({x, w});
    p[i].first = x;
    p[i].second = y;
  }
  for (int i = 1; i <= n; i++) dijkstra(i);
  for (int i = 1; i <= k; i++) cin >> r[i].first >> r[i].second;
  long long ans = 0;
  for (int i = 1; i <= k; i++) ans = ans + d[r[i].first][r[i].second];
  for (int i = 1; i <= m; i++) {
    long long sum = 0;
    for (int j = 1; j <= k; j++) {
      long long w1 = d[r[j].first][p[i].first] + d[r[j].second][p[i].second];
      long long w2 = d[r[j].second][p[i].first] + d[r[j].first][p[i].second];
      sum = sum + min(d[r[j].first][r[j].second], min(w1, w2));
    }
    ans = min(ans, sum);
  }
  cout << ans << '\n';
}
int main() {
  int t = 1;
  while (t--) solve();
  return 0;
}
