#include <bits/stdc++.h>
using namespace std;
void start() {}
const long long N = 1005;
long long n, m, k1;
vector<pair<long long, long long> > adj[N];
map<pair<long long, long long>, long long> mp, mp1;
vector<long long> v1[N];
void spee(long long src) {
  set<pair<long long, long long> > setds;
  vector<long long> dist(N, 5e18);
  setds.insert({0, src});
  dist[src] = 0;
  long long parent[N];
  memset(parent, -1, sizeof(parent));
  while (!setds.empty()) {
    pair<long long, long long> tmp = *(setds.begin());
    setds.erase(setds.begin());
    long long u = tmp.second;
    for (auto i = adj[u].begin(); i != adj[u].end(); ++i) {
      long long v = (*i).first;
      long long weight = (*i).second;
      if (dist[v] > dist[u] + weight) {
        if (dist[v] != 5e18) setds.erase(setds.find({dist[v], v}));
        dist[v] = dist[u] + weight;
        setds.insert({dist[v], v});
      }
    }
  }
  for (long long i = 0; i < n; i++) {
    v1[src].push_back(dist[i]);
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m >> k1;
  for (long long i = 0; i < m; i++) {
    long long x, y, z;
    cin >> x >> y >> z;
    x--;
    y--;
    adj[x].push_back({y, z});
    adj[y].push_back({x, z});
    mp[{x, y}] = z;
    mp[{y, x}] = z;
  }
  for (long long i = 0; i < n; i++) {
    spee(i);
  }
  long long sum1 = 5e18;
  vector<pair<long long, long long> > vec;
  for (long long i = 0; i < k1; i++) {
    long long sum = 5e18;
    long long x, y;
    cin >> x >> y;
    x--;
    y--;
    vec.push_back({x, y});
  }
  for (long long j = 0; j < n; j++) {
    for (long long k = 0; k < adj[j].size(); k++) {
      long long sum = 0;
      for (long long i = 0; i < k1; i++) {
        long long x = vec[i].first;
        long long y = vec[i].second;
        sum += min({v1[x][y], v1[x][j] + v1[adj[j][k].first][y],
                    v1[x][adj[j][k].first] + v1[j][y]});
      }
      sum1 = min(sum, sum1);
    }
  }
  cout << sum1 << endl;
}
