#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
const int N = 1999;
const int inf = 1e9;
int n, m, k;
vector<ii> g[N];
vector<pair<ii, int>> adj;
int d[N][N];
void dijkstra(int v, int ind) {
  fill(d[ind], d[ind] + N, inf);
  set<ii> info;
  info.insert({0, v});
  d[ind][v] = 0;
  while ((int)info.size()) {
    int vinf = info.begin()->second;
    int winf = info.begin()->first;
    info.erase(info.begin());
    for (ii to : g[vinf]) {
      if (d[ind][to.first] > winf + to.second) {
        info.erase({d[ind][to.first], to.first});
        d[ind][to.first] = winf + to.second;
        info.insert({d[ind][to.first], to.first});
      }
    }
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0, u, v, c; i < m; i++) {
    scanf("%d%d%d", &u, &v, &c), --u, --v;
    g[u].push_back({v, c});
    g[v].push_back({u, c});
    adj.push_back({{u, v}, c});
  }
  vector<ii> motions;
  for (int i = 0, x, y; i < k; i++) {
    scanf("%d%d", &x, &y), --x, --y;
    motions.push_back({x, y});
  }
  for (int i = 0; i < n; i++) {
    dijkstra(i, i);
  }
  int ans = 1e9;
  for (pair<ii, int> t : adj) {
    int c = 0;
    for (int path = 0; path < k; path++) {
      int x = motions[path].first, y = motions[path].second;
      c += min({d[x][y], d[x][t.first.first] + d[t.first.second][y],
                d[x][t.first.second] + d[t.first.first][y]});
    }
    ans = min(ans, c);
  }
  printf("%d\n", ans);
}
