#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x3f3f3f3f;
const int maxn = 1e3 + 7;
vector<pair<int, int> > G[maxn];
vector<pair<int, int> > vec, edges;
int dis[maxn][maxn], vis[maxn];
void dijkstra(int sta) {
  memset(dis[sta], 0x3f, sizeof(dis[sta]));
  memset(vis, 0, sizeof(vis));
  priority_queue<pair<int, int> > q;
  dis[sta][sta] = 0;
  q.push({0, sta});
  while (!q.empty()) {
    int now = q.top().second;
    q.pop();
    if (vis[now]) continue;
    vis[now] = 1;
    for (int i = 0; i < G[now].size(); i++) {
      int v = G[now][i].first, w = G[now][i].second;
      if (dis[sta][v] > dis[sta][now] + w) {
        dis[sta][v] = dis[sta][now] + w;
        q.push({-dis[sta][v], v});
      }
    }
  }
}
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= m; i++) {
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    edges.push_back({x, y});
    G[x].push_back({y, z});
    G[y].push_back({x, z});
  }
  for (int i = 1; i <= k; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    vec.push_back({x, y});
  }
  for (int i = 1; i <= n; i++) {
    dijkstra(i);
  }
  long long ans = 0;
  for (int i = 0; i < k; i++) {
    int x = vec[i].first, y = vec[i].second;
    ans += dis[x][y];
  }
  for (int i = 0; i < edges.size(); i++) {
    int X = edges[i].first, Y = edges[i].second;
    long long tmp = 0;
    for (int j = 0; j < k; j++) {
      int x = vec[j].first, y = vec[j].second;
      tmp += min(dis[x][y], min(dis[x][Y] + dis[X][y], dis[x][X] + dis[Y][y]));
    }
    ans = min(ans, tmp);
  }
  printf("%lld\n", ans);
  return 0;
}
