#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
const int INF = 1e9 + 9;
const int N = 1e3 + 5;
vector<vector<pair<int, int>>> v(N);
vector<vector<int>> dis(N, vector<int>(N, INF));
vector<pair<int, int>> edges;
vector<pair<int, int>> q;
int n, m, k;
void solve() {
  for (int i = 1; i <= n; i++) {
    priority_queue<pair<int, int>, vector<pair<int, int>>,
                   greater<pair<int, int>>>
        pq;
    dis[i][i] = 0;
    pq.push({0, i});
    while (!pq.empty()) {
      auto t = pq.top();
      pq.pop();
      if (dis[i][t.second] < t.first) continue;
      for (auto &x : v[t.second])
        if (dis[i][x.first] > dis[i][t.second] + x.second) {
          dis[i][x.first] = dis[i][t.second] + x.second;
          pq.push({dis[i][x.first], x.first});
        }
    }
  }
  int ans = INF;
  for (auto &i : edges) {
    int sum = 0;
    for (auto &j : q)
      sum += min({dis[j.first][j.second],
                  dis[j.first][i.first] + dis[i.second][j.second],
                  dis[j.first][i.second] + dis[i.first][j.second]});
    ans = min(ans, sum);
  }
  cout << ans << "\n";
}
int main() {
  fast();
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    int a, b, w;
    cin >> a >> b >> w;
    v[a].emplace_back(b, w);
    v[b].emplace_back(a, w);
    edges.push_back({a, b});
  }
  for (int i = 0; i < k; i++) {
    int a, b;
    cin >> a >> b;
    q.emplace_back(a, b);
  }
  solve();
}
