#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 228;
const long long infll = 1e18;
const long long MOD = 1e9 + 7;
const long double eps = 1e-5;
const int K = 31;
const long double eps2 = 1e-9;
const long long MOD2 = 998244353;
const long long dosz = 5e5;
const long long SZ = (1 << 18);
const long double PI = 3.1415926535;
void fast_io() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}
const int maxn = 1001;
vector<pair<int, int> > g[maxn];
int n, m, k;
vector<int> djks(int j) {
  vector<int> dist(n, inf);
  dist[j] = 0;
  priority_queue<pair<int, int> > q;
  q.push(make_pair(0, j));
  while (!q.empty()) {
    int v = q.top().second;
    q.pop();
    for (pair<int, int> i : g[v]) {
      if (dist[i.first] > dist[v] + i.second) {
        dist[i.first] = dist[v] + i.second;
        q.push(make_pair(-dist[i.first], i.first));
      }
    }
  }
  return dist;
}
void solve() {
  cin >> n >> m >> k;
  vector<pair<int, int> > abc(m);
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    abc[i] = make_pair(a, b);
    g[a].push_back(make_pair(b, c));
    g[b].push_back(make_pair(a, c));
  }
  vector<pair<int, int> > lol;
  for (int i = 0; i < k; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    lol.push_back(make_pair(a, b));
  }
  vector<vector<int> > kek(n);
  for (int i = 0; i < n; i++) {
    kek[i] = djks(i);
  }
  vector<int> dist(k, inf);
  int ans = inf;
  for (int i = 0; i < m; i++) {
    int a, b;
    a = abc[i].first;
    b = abc[i].second;
    int cur = 0;
    for (int j = 0; j < k; j++) {
      cur += min(kek[lol[j].first][lol[j].second],
                 min(kek[lol[j].first][a] + kek[b][lol[j].second],
                     kek[lol[j].first][b] + kek[a][lol[j].second]));
    }
    ans = min(ans, cur);
  }
  cout << ans << '\n';
}
signed main() {
  fast_io();
  srand(time(NULL));
  int q = 1;
  while (q--) solve();
}
