#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int N = 1005;
vector<pair<int, int>> adj[N];
int d[N][N];
void dijkstra(int u) {
  set<pair<int, int>> st;
  st.insert({0, u});
  d[u][u] = 0;
  while (!st.empty()) {
    pair<int, int> t = *st.begin();
    st.erase(st.begin());
    int v = t.second, c = t.first;
    for (auto i : adj[v]) {
      if (d[u][i.first] > c + i.second) {
        st.erase({d[u][i.first], i.first});
        d[u][i.first] = i.second + c;
        st.insert({d[u][i.first], i.first});
      }
    }
  }
}
void solve() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    int p, q, r;
    cin >> p >> q >> r;
    adj[p].push_back({q, r});
    adj[q].push_back({p, r});
  }
  vector<pair<int, int>> r;
  for (int i = 0; i < k; i++) {
    int a, b;
    cin >> a >> b;
    r.push_back({a, b});
  }
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= n; j++) d[i][j] = 1e8;
  for (int i = 1; i <= n; i++) dijkstra(i);
  int ans = INT_MAX;
  for (int x = 1; x <= n; x++) {
    for (auto z : adj[x]) {
      int y = z.first;
      int temp = 0;
      for (auto t : r) {
        int p = t.first, q = t.second;
        temp += min({d[p][q], d[p][x] + d[y][q], d[p][y] + d[x][q]});
      }
      ans = min(ans, temp);
    }
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  solve();
}
