#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
vector<pair<int, int>> e[N];
int dis[N][N];
void dijkstra(int s) {
  dis[s][s] = 0;
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      q;
  q.push({0, s});
  while (!q.empty()) {
    auto p = q.top();
    q.pop();
    int u = p.second;
    for (auto& [v, w] : e[u]) {
      if (dis[s][v] > dis[s][u] + w) {
        dis[s][v] = dis[s][u] + w;
        q.push({dis[s][v], v});
      }
    }
  }
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<pair<int, int>> edge;
  for (int i = 0; i < m; i++) {
    int first, second, w;
    cin >> first >> second >> w;
    e[first].push_back({second, w});
    e[second].push_back({first, w});
    edge.push_back({first, second});
  }
  vector<pair<int, int>> r;
  for (int i = 0; i < k; i++) {
    int a, b;
    cin >> a >> b;
    r.push_back({a, b});
  }
  memset(dis, 0x3f, sizeof(dis));
  for (int i = 1; i <= n; i++) {
    dijkstra(i);
  }
  int res = 0x3f3f3f3f;
  for (auto& [u, v] : edge) {
    int cnt = 0;
    for (auto& [a, b] : r) {
      cnt += min({dis[a][b], dis[a][u] + dis[v][b], dis[a][v] + dis[u][b]});
    }
    res = min(res, cnt);
  }
  cout << res << endl;
}
