#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> graph[1001];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m, kk;
  cin >> n >> m >> kk;
  for (int i = 0; i < m; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    graph[x].push_back({y, z});
    graph[y].push_back({x, z});
  }
  vector<pair<int, int>> del;
  for (int i = 0; i < kk; i++) {
    int x, y;
    cin >> x >> y;
    del.push_back({x, y});
  }
  vector<vector<int>> dis(n + 1, vector<int>(n + 1, INT_MAX / 2));
  for (int i = 1; i <= n; i++) {
    priority_queue<pair<int, int>, vector<pair<int, int>>,
                   greater<pair<int, int>>>
        q;
    dis[i][i] = 0;
    q.push({0, i});
    while (!q.empty()) {
      pair<int, int> top = q.top();
      q.pop();
      if (dis[i][top.second] != top.first) {
        continue;
      }
      for (int j = 0; j < graph[top.second].size(); j++) {
        if (dis[i][top.second] + graph[top.second][j].second <
            dis[i][graph[top.second][j].first]) {
          dis[i][graph[top.second][j].first] =
              dis[i][top.second] + graph[top.second][j].second;
          q.push(
              {dis[i][graph[top.second][j].first], graph[top.second][j].first});
        }
      }
    }
  }
  int ans = INT_MAX;
  for (int j = 1; j <= n; j++) {
    for (int k = 0; k < graph[j].size(); k++) {
      int tans = 0;
      for (int i = 0; i < kk; i++) {
        int a = del[i].first;
        int b = del[i].second;
        tans += min(dis[a][b], min(dis[a][j] + dis[graph[j][k].first][b],
                                   dis[j][b] + dis[a][graph[j][k].first]));
      }
      ans = min(ans, tans);
    }
  }
  cout << ans << endl;
  return 0;
}
