#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using VI = vector<int>;   using PII = pair<int, int>;   const int N = 1005, INF = 1e9;   vector<PII> adj[N];   int dis[N][N];   int main() {     int n, m, k;     cin >> n >> m >> k;     vector<tuple<int, int, int>> edges;     for (int i = 0; i < m; i++) {       int u, v, w;       cin >> u >> v >> w;       adj[u].emplace_back(v, w);       adj[v].emplace_back(u, w);       edges.emplace_back(u, v, w);     }     vector<PII> paths(k);     for (auto &[u, v] : paths) cin >> u >> v;     for (int s = 1; s <= n; s++) {       for (int u = 1; u <= n; u++) {         dis[s][u] = s == u ? 0 : INF;       }       priority_queue<PII> heap;       heap.emplace(0, s);       while (!heap.empty()) {         int u = heap.top().second;         heap.pop();         for (auto [v, w] : adj[u]) {           if (dis[s][v] > dis[s][u] + w) {             dis[s][v] = dis[s][u] + w;             heap.emplace(-dis[s][v], v);           }         }       }     }     ll ans = 1e18;     for (auto [u, v, w] : edges) {       ll cur = 0;       for (auto [x, y] : paths) {         cur += min({dis[x][y], dis[x][u] + dis[v][y], dis[x][v] + dis[u][y]});       }       ans = min(ans, cur);     }     cout << ans << endl;     return 0;   }   