#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 10;
typedef pair<long long, long long> P;
long long dis[maxn];
long long n, m, k, start;
struct edge {
  long long to, cost;
};
vector<edge> g[maxn];
long long f[maxn][maxn];
bool vis[maxn];
void dijkstra() {
  long long s = start;
  memset(dis, 0x3f, sizeof(dis));
  memset(vis, 0, sizeof(vis));
  dis[s] = 0;
  priority_queue<P, vector<P>, greater<P> > que;
  que.push({0, s});
  while (!que.empty()) {
    P p = que.top();
    que.pop();
    long long v = p.second;
    if (vis[v]) continue;
    vis[v] = 1;
    for (long long i = 0; i < g[v].size(); ++i) {
      edge e = g[v][i];
      if (dis[e.to] > dis[v] + e.cost) {
        dis[e.to] = dis[v] + e.cost;
        que.push({dis[e.to], e.to});
      }
    }
  }
  for (long long j = 1; j <= n; ++j) {
    f[s][j] = dis[j];
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n >> m >> k;
  vector<pair<long long, long long> > Edge;
  for (long long i = 1; i <= m; ++i) {
    long long u, v, w;
    cin >> u >> v >> w;
    g[u].push_back({v, w});
    g[v].push_back({u, w});
    Edge.push_back({u, v});
  }
  vector<pair<long long, long long> > v;
  for (long long i = 1; i <= k; ++i) {
    long long a, b;
    cin >> a >> b;
    v.push_back({a, b});
  }
  for (long long i = 1; i <= n; ++i) {
    start = i;
    dijkstra();
  }
  long long sum = 1e18;
  for (auto i : Edge) {
    long long a = i.first;
    long long b = i.second;
    long long ans = 0;
    for (auto j : v) {
      ans += min(f[j.first][j.second], min(f[j.first][a] + f[j.second][b],
                                           f[j.first][b] + f[j.second][a]));
    }
    sum = min(sum, ans);
  }
  cout << sum << endl;
  return 0;
}
