#include <bits/stdc++.h>
using namespace std;
const int N = 1e3;
const long long oo = 1e15 + 5;
int du[] = {-1, 0, 0, 1};
int dv[] = {0, -11, 1, 0};
const long long mod = 1e9 + 7;
long long sqr(long long x) { return x * x; }
int getbit(int state, int i) { return ((state >> i) & 1); }
int n, m, k;
pair<int, int> a[N + 5];
long long res, d[N + 5][N + 5];
vector<int> g[N + 5];
struct Clara {
  int u, v;
  long long w;
  Clara(int U = 0, int V = 0, long long W = 0) {
    u = U;
    v = V;
    w = W;
  }
  int get(int x) { return u + v - x; }
} edge[N + 5];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m >> k;
  for (int i = 1; i <= m; i++) {
    int u, v;
    long long w;
    cin >> u >> v >> w;
    edge[i] = Clara(u, v, w);
    g[u].push_back(i);
    g[v].push_back(i);
  }
  for (int now = 1; now <= n; now++) {
    priority_queue<pair<int, int>, vector<pair<int, int> >,
                   greater<pair<int, int> > >
        q;
    for (int i = 1; i <= n; i++) d[now][i] = oo;
    d[now][now] = 0;
    q.push(pair<int, int>(0, now));
    while (!q.empty()) {
      pair<int, int> tmp = q.top();
      q.pop();
      int u = tmp.second;
      long long du = tmp.first;
      if (du != d[now][u]) continue;
      for (int i = 0; i < g[u].size(); i++) {
        int id = g[u][i];
        int v = edge[id].get(u);
        long long uv = edge[id].w;
        if (d[now][v] > du + uv) {
          d[now][v] = du + uv;
          q.push(pair<int, int>(d[now][v], v));
        }
      }
    }
  }
  for (int i = 1; i <= k; i++) {
    cin >> a[i].first >> a[i].second;
    res += d[a[i].first][a[i].second];
  }
  for (int i = 1; i <= m; i++) {
    long long now = 0;
    int u = edge[i].u, v = edge[i].v;
    for (int j = 1; j <= k; j++) {
      int s = a[j].first, t = a[j].second;
      if (d[s][u] + d[v][t] <= d[s][t])
        now += d[s][u] + d[v][t];
      else if (d[s][v] + d[u][t] <= d[s][t])
        now += d[s][v] + d[u][t];
      else
        now += d[s][t];
    }
    res = min(res, now);
  }
  cout << res;
  return 0;
}
