#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int N = 1000;
vector<vector<pair<int, int>>> g;
vector<vector<int>> dis;
vector<bool> vis;
void dijkstra(int s) {
  priority_queue<pair<long long, long long>> q;
  q.push({0, s});
  while (!q.empty()) {
    long long a = q.top().second;
    q.pop();
    if (vis[a]) continue;
    vis[a] = true;
    for (auto u : g[a]) {
      long long b = u.first, w = u.second;
      if (dis[s][a] + w < dis[s][b]) {
        dis[s][b] = dis[s][a] + w;
        q.push({-dis[s][b], b});
      }
    }
  }
}
void solve() {
  int n, m, k;
  cin >> n >> m >> k;
  g.assign(n, vector<pair<int, int>>());
  vector<pair<int, int>> edges;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    g[a].push_back({b, c});
    g[b].push_back({a, c});
    edges.push_back({a, b});
  }
  dis.assign(n, vector<int>(n, INT_MAX));
  for (int i = 0; i < n; i++) {
    vis.assign(n, false);
    dis[i][i] = 0;
    dijkstra(i);
  }
  vector<pair<int, int>> cities;
  for (int i = 0; i < k; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    cities.push_back({a, b});
  }
  long long ans = 1e18;
  for (auto i : edges) {
    int x = i.first, y = i.second;
    long long cur = 0;
    for (int i = 0; i < k; i++) {
      int a = cities[i].first, b = cities[i].second;
      int d = dis[a][b];
      d = min({d, dis[a][x] + dis[y][b], dis[b][x] + dis[y][a]});
      cur += d;
    }
    ans = min(ans, cur);
  }
  cout << ans << '\n';
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
