#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 10;
const int INF = 1e9 + 10;
struct P {
  int n, d;
  bool operator<(const P& rhs) const { return d > rhs.d; }
};
int d[maxn][maxn];
int n, m, k;
int s[maxn], e[maxn], E1[maxn], E2[maxn];
vector<pair<int, int> > G[maxn];
bool done[maxn];
void dijkstra(int s) {
  memset(done, 0, sizeof(done));
  for (int i = 1; i <= n; i++) d[s][i] = INF;
  priority_queue<P> q;
  d[s][s] = 0;
  q.push((P){s, 0});
  while (!q.empty()) {
    P u = q.top();
    q.pop();
    if (done[u.n]) continue;
    done[u.n] = true;
    for (int i = 0; i < G[u.n].size(); i++) {
      int v = G[u.n][i].first;
      if (d[s][v] > d[s][u.n] + G[u.n][i].second) {
        d[s][v] = d[s][u.n] + G[u.n][i].second;
        q.push((P){v, d[s][v]});
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    E1[i] = a;
    E2[i] = b;
    G[a].push_back(make_pair(b, c));
    G[b].push_back(make_pair(a, c));
  }
  for (int i = 0; i < k; i++) cin >> s[i] >> e[i];
  for (int i = 1; i <= n; i++) dijkstra(i);
  int ans = INF;
  for (int i = 0; i < m; i++) {
    int now = 0;
    for (int j = 0; j < k; j++) {
      now += min(d[s[j]][e[j]], min(d[s[j]][E1[i]] + d[E2[i]][e[j]],
                                    d[s[j]][E2[i]] + d[E1[i]][e[j]]));
    }
    ans = min(ans, now);
  }
  cout << ans << endl;
}
