#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &res) {
  bool flag = false;
  char ch;
  while (!isdigit(ch = getchar())) (ch == '-') && (flag = true);
  for (res = ch - 48; isdigit(ch = getchar());
       res = (res << 1) + (res << 3) + ch - 48)
    ;
  flag && (res = -res);
}
template <typename T>
void Out(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) Out(x / 10);
  putchar(x % 10 + '0');
}
const long long N = 2e3 + 10, inf = 0x3f3f3f3f;
long long p[N], q[N];
long long u[N], v[N], w[N];
bool vis[N];
long long dis[N][N];
struct node {
  long long v;
  long long c;
  bool operator<(const node &r) const { return c > r.c; }
};
struct Edge {
  long long v, cost;
};
vector<Edge> e[N];
void dijkstra(long long k, long long n, long long s) {
  memset(vis, 0, sizeof(vis));
  for (long long i = 1; i <= n; i++) {
    dis[k][i] = inf;
  }
  priority_queue<node> q;
  dis[k][s] = 0;
  q.push({s, 0});
  while (!q.empty()) {
    node temp = q.top();
    q.pop();
    long long u = temp.v;
    if (vis[u]) continue;
    vis[u] = 1;
    for (long long i = 0; i < e[u].size(); i++) {
      long long v = e[temp.v][i].v;
      long long cost = e[u][i].cost;
      if (!vis[v] && dis[k][v] > dis[k][u] + cost) {
        dis[k][v] = dis[k][u] + cost;
        q.push({v, dis[k][v]});
      }
    }
  }
}
signed main() {
  long long n, m, k;
  cin >> n >> m >> k;
  for (long long i = 1; i <= m; i++) {
    cin >> u[i] >> v[i] >> w[i];
    e[u[i]].push_back({v[i], w[i]});
    e[v[i]].push_back({u[i], w[i]});
  }
  for (long long i = 1; i <= k; i++) {
    cin >> p[i] >> q[i];
  }
  for (long long i = 1; i <= k; i++) {
    dijkstra(i, n, p[i]);
  }
  for (long long i = 1; i <= k; i++) {
    dijkstra(i + k, n, q[i]);
  }
  long long ans = inf;
  for (long long i = 1; i <= m; i++) {
    long long cnt = 0;
    for (long long j = 1; j <= k; j++) {
      cnt += min(min(dis[j][q[j]], dis[j][u[i]] + dis[j + k][v[i]]),
                 dis[j][v[i]] + dis[j + k][u[i]]);
    }
    ans = min(ans, cnt);
  }
  cout << ans << '\n';
  return 0;
}
