#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
const int INF = 1e9 + 7;
int dist[N][N];
void minimize(int& x, int y) {
  if (x > y) {
    x = y;
  }
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int x = 1; x <= n; x++) {
    for (int y = 1; y <= n; y++) {
      dist[x][y] = (x == y ? 0 : INF);
    }
  }
  vector<int> X(m), Y(m), W(m);
  for (int i = 0; i < m; i++) {
    int x, y, w;
    scanf("%d%d%d", &x, &y, &w);
    X[i] = x, Y[i] = y, W[i] = w;
    minimize(dist[x][y], w);
    minimize(dist[y][x], w);
  }
  vector<int> a(k), b(k);
  for (int i = 0; i < k; i++) {
    scanf("%d%d", &a[i], &b[i]);
  }
  for (int z = 1; z <= n; z++) {
    for (int x = 1; x <= n; x++) {
      for (int y = 1; y <= n; y++) {
        minimize(dist[x][y], dist[x][z] + dist[z][y]);
      }
    }
  }
  int answer = 0;
  for (int j = 0; j < k; j++) {
    answer += dist[a[j]][b[j]];
  }
  for (int i = 0; i < m; i++) {
    int current = 0;
    for (int j = 0; j < k; j++) {
      current += min({dist[a[j]][b[j]], dist[a[j]][X[i]] + dist[Y[i]][b[j]],
                      dist[a[j]][Y[i]] + dist[X[i]][b[j]]});
    }
    minimize(answer, current);
  }
  cout << answer << endl;
}
