#include <bits/stdc++.h>
using namespace std;
const long long int N = 1001;
long long int n, m, k;
vector<pair<long long int, long long int> > adj[N];
vector<long long int> func(long long int x) {
  vector<long long int> dis(n + 1, INT_MAX);
  if (x == 0) {
    return dis;
  }
  vector<int> vis(n + 1, 0);
  set<pair<long long int, long long int> > s;
  s.insert(make_pair(0, x));
  dis[x] = 0;
  while (!s.empty()) {
    long long int v = (*s.begin()).second;
    s.erase(s.begin());
    if (vis[v]) {
      continue;
    }
    vis[v] = 1;
    for (auto u : adj[v]) {
      if (dis[u.first] > dis[v] + u.second) {
        dis[u.first] = dis[v] + u.second;
        s.insert(make_pair(dis[u.first], u.first));
      }
    }
  }
  return dis;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m >> k;
  vector<pair<pair<long long int, long long int>, long long int> > edges;
  for (long long int i = 0; i < m; ++i) {
    long long int a, b, w;
    cin >> a >> b >> w;
    adj[a].push_back(make_pair(b, w));
    adj[b].push_back(make_pair(a, w));
    edges.push_back(make_pair(make_pair(a, b), w));
  }
  vector<pair<long long int, long long int> > queries(k);
  for (long long int i = 0; i < k; ++i) {
    cin >> queries[i].first >> queries[i].second;
  }
  vector<vector<long long int> > dis;
  for (long long int i = 0; i <= n; ++i) {
    dis.push_back(func(i));
  }
  long long int ans = 0;
  for (long long int i = 0; i < k; ++i) {
    ans += dis[queries[i].first][queries[i].second];
  }
  for (long long int i = 0; i < m; ++i) {
    long long int a = edges[i].first.first;
    long long int b = edges[i].first.second;
    long long int w = edges[i].second;
    long long int cost = 0;
    for (long long int j = 0; j < k; ++j) {
      long long int x = queries[j].first, y = queries[j].second;
      long long int price = dis[x][y];
      if (dis[x][a] < dis[x][b] && dis[y][a] > dis[y][b]) {
        price = min(price, dis[x][a] + dis[b][y]);
      } else if (dis[x][b] < dis[x][a] && dis[y][a] < dis[y][b]) {
        price = min(price, dis[x][b] + dis[y][a]);
      }
      cost += price;
    }
    ans = min(ans, cost);
  }
  cout << ans;
  return (0);
}
