#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream &operator<<(ostream &out, vector<T> &A) {
  for (long long i = 0; i < (long long)A.size(); i++) out << A[i] << " ";
  return out;
}
long long power(long long a, long long b);
const long long mod = 1000000007;
const long long inf = 1e10;
const long long N = 1005;
long long dis[N][N], edge[N][3];
vector<pair<long long, long long> > g[N];
vector<long long> vis(N, 0);
void dijk(long long s) {
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> >,
                 greater<pair<long long, long long> > >
      q;
  q.push({0, s});
  dis[s][s] = 0;
  while (!q.empty()) {
    pair<long long, long long> p = q.top();
    q.pop();
    if (vis[p.second]) continue;
    vis[p.second] = 1;
    for (auto c : g[p.second]) {
      if (dis[s][c.first] > dis[s][p.second] + c.second) {
        dis[s][c.first] = dis[s][p.second] + c.second;
        q.push({dis[s][c.first], c.first});
      }
    }
  }
  for (long long i = 0; i < N; i++) vis[i] = 0;
}
void solve() {
  long long n, m, k;
  cin >> n >> m >> k;
  for (long long i = 0; i < m; i++) {
    long long x, y, w;
    cin >> x >> y >> w;
    edge[i][0] = x, edge[i][1] = y, edge[i][2] = w;
    g[x].push_back({y, w});
    g[y].push_back({x, w});
  }
  for (long long i = 0; i < N; i++)
    for (long long j = 0; j < N; j++) dis[i][j] = inf;
  for (long long i = 1; i < n + 1; i++) dijk(i);
  long long p[k][2];
  for (long long i = 0; i < k; i++) {
    cin >> p[i][0] >> p[i][1];
  }
  long long res = inf;
  for (long long i = 0; i < m; i++) {
    long long temp = 0;
    long long x = edge[i][0], y = edge[i][1];
    for (long long j = 0; j < k; j++) {
      long long a = p[j][0], b = p[j][1];
      temp += min(dis[a][b], min(dis[a][x] + dis[y][b], dis[a][y] + dis[x][b]));
    }
    res = min(res, temp);
  }
  cout << res << '\n';
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
long long power(long long a, long long b) {
  long long ans = 1;
  while (b > 0) {
    if (b & 1) {
      ans = (ans * a) % mod;
    }
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}
