#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int maxN = 1e3 + 10;
const int oo = 1e9 + 10;
int n, m, Q, a[maxN][maxN], p[maxN][maxN], res = oo, d[maxN];
pair<int, int> q[maxN];
int ok[maxN][maxN];
bool vst[maxN];
vector<pair<int, int> > adj[maxN];
struct iii {
  int x, y, w;
};
vector<iii> edges;
void input() {
  cin >> n >> m >> Q;
  for (int i = int(1); i <= int(m); ++i) {
    int x, y, z;
    cin >> x >> y >> z;
    edges.push_back({x, y, z});
    adj[x].push_back(pair<int, int>(z, y));
    adj[y].push_back(pair<int, int>(z, x));
  }
  for (int i = int(1); i <= int(Q); ++i) {
    cin >> q[i].first >> q[i].second;
  }
}
void Dijkstra(int u, int idx) {
  for (int i = int(1); i <= int(n); ++i) d[i] = oo, vst[i] = 0;
  d[u] = 0;
  priority_queue<pair<int, int> > q;
  q.push(pair<int, int>(0, u));
  while (q.size()) {
    u = q.top().second;
    q.pop();
    if (vst[u]) continue;
    vst[u] = 1;
    for (auto t : adj[u]) {
      int v = t.second;
      int w = t.first;
      if (d[u] + w < d[v]) {
        d[v] = d[u] + w;
        q.push(pair<int, int>(-d[v], v));
      }
    }
  }
  for (int i = int(1); i <= int(n); ++i) {
    a[idx][i] = d[i];
  }
}
void solve() {
  for (int i = int(1); i <= int(n); ++i) Dijkstra(i, i);
  for (int i = int(0); i <= int(m - 1); ++i) {
    int u = edges[i].x;
    int v = edges[i].y;
    int tmp = 0;
    for (int j = int(1); j <= int(Q); ++j) {
      int x = q[j].first;
      int y = q[j].second;
      int tmp2 = min({a[x][u] + a[v][y], a[x][v] + a[u][y], a[x][y]});
      tmp += tmp2;
    }
    res = min(res, tmp);
  }
}
void output() { cout << res; }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  input();
  solve();
  output();
}
