#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
vector<pair<int, int> > g[MAXN];
int dist[MAXN][MAXN];
int cost[MAXN];
void bfs(int x, int n) {
  queue<int> q;
  q.push(x);
  for (int i = 0; i < n; i++) dist[x][i] = 1e9;
  dist[x][x] = 0;
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (auto e : g[v]) {
      if (dist[x][e.first] > dist[x][v] + e.second)
        dist[x][e.first] = dist[x][v] + e.second, q.push(e.first);
    }
  }
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<pair<int, int> > ed;
  for (int i = 0; i < m; i++) {
    int x, y, w;
    cin >> x >> y >> w;
    g[x - 1].push_back({y - 1, w});
    g[y - 1].push_back({x - 1, w});
    cost[i] = w;
    ed.push_back({x - 1, y - 1});
  }
  for (int i = 0; i < n; i++) bfs(i, n);
  vector<pair<int, int> > p;
  for (int i = 0; i < k; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    p.push_back({a, b});
  }
  long long res = 1e18;
  for (int i = 0; i < m; i++) {
    long long tot = 0;
    for (auto x : p) {
      tot += min({dist[x.first][x.second],
                  dist[x.first][ed[i].first] + dist[ed[i].second][x.second],
                  dist[x.first][ed[i].second] + dist[ed[i].first][x.second]});
    }
    res = min(res, tot);
  }
  cout << res << '\n';
  return 0;
}
