#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
const int inf = 0x3f3f3f3f;
struct Edge {
  int to, cost;
  bool operator<(const Edge &q) const { return cost > q.cost; }
};
vector<Edge> e[N];
int dis[N][N];
bool vis[N];
priority_queue<Edge> qu;
void diji(int st, int n) {
  for (int i = 1; i <= n; ++i) dis[st][i] = inf, vis[i] = false;
  dis[st][st] = 0;
  qu.push({st, 0});
  while (!qu.empty()) {
    Edge f = qu.top();
    qu.pop();
    if (vis[f.to]) continue;
    vis[f.to] = true;
    for (Edge s : e[f.to]) {
      if (vis[s.to] || dis[st][s.to] <= dis[st][f.to] + s.cost) continue;
      dis[st][s.to] = dis[st][f.to] + s.cost;
      qu.push({s.to, dis[st][s.to]});
    }
  }
}
int uu[N], vv[N], eu[N], ev[N];
int main() {
  int n, m, k;
  while (~scanf("%d%d%d", &n, &m, &k)) {
    for (int i = 1; i <= n; ++i) e[i].clear();
    for (int i = 1; i <= m; ++i) {
      int u, v, x;
      scanf("%d%d%d", &u, &v, &x);
      e[u].push_back({v, x});
      e[v].push_back({u, x});
      eu[i] = u;
      ev[i] = v;
    }
    for (int i = 1; i <= n; ++i) diji(i, n);
    for (int i = 1; i <= k; ++i) scanf("%d%d", &uu[i], &vv[i]);
    int ans = inf;
    for (int i = 1; i <= m; ++i) {
      int res = 0;
      for (int j = 1; j <= k; ++j) {
        res +=
            min(dis[uu[j]][vv[j]], min(dis[uu[j]][eu[i]] + dis[ev[i]][vv[j]],
                                       dis[uu[j]][ev[i]] + dis[eu[i]][vv[j]]));
      }
      ans = min(ans, res);
    }
    printf("%d\n", ans);
  }
  return 0;
}
