#include <bits/stdc++.h>
const int N = 1111;
const int oo = 1e7;
using namespace std;
pair<int, int> b[N];
bool cx[N];
int n, m, k, ans;
int c[N][N], d[N][N];
vector<int> adj[N];
struct dt {
  int u, v, w;
} a[N];
void Rin() {
  ans = 100 * oo;
  memset(cx, false, sizeof(cx));
  cin >> n >> m >> k;
  for (int x = 1; x <= n; x++)
    for (int y = 1; y <= n; y++) c[x][y] = c[y][x] = oo;
  for (int x = 1; x <= m; x++) {
    cin >> a[x].u >> a[x].v >> a[x].w;
    int g = a[x].u, h = a[x].v;
    c[g][h] = c[h][g] = min(c[g][h], a[x].w);
    adj[g].push_back(h);
    adj[h].push_back(g);
  }
  for (int x = 1; x <= k; x++) {
    cin >> b[x].first >> b[x].second;
    if (b[x].first > b[x].second) swap(b[x].first, b[x].second);
    cx[b[x].first] = true;
  }
}
void DJK(int s) {
  for (int x = 1; x <= n; x++) d[s][x] = oo;
  d[s][s] = 0;
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      pq;
  pq.push({0, s});
  while (pq.size()) {
    int g = pq.top().first, h = pq.top().second;
    pq.pop();
    if (g != d[s][h]) continue;
    for (auto x : adj[h]) {
      if (d[s][x] > g + c[x][h]) {
        d[s][x] = g + c[x][h];
        pq.push({d[s][x], x});
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  Rin();
  for (int x = 1; x <= n; x++) DJK(x);
  for (int x = 1; x <= m; x++) {
    int res = 0;
    for (int y = 1; y <= k; y++)
      res += min(d[b[y].first][b[y].second],
                 min(d[b[y].first][a[x].u] + d[a[x].v][b[y].second],
                     d[b[y].first][a[x].v] + d[a[x].u][b[y].second]));
    ans = min(ans, res);
  }
  cout << ans;
}
