#include <bits/stdc++.h>
using namespace std;
pair<int, int> res[1000];
struct edge {
  int to, cost;
};
vector<edge> G[1001];
struct data {
  int from, to;
};
int dis[1001][1001];
data go[1000];
void dfs(int s) {
  dis[s][s] = 0;
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      q;
  q.push(pair<int, int>(0, s));
  while (!q.empty()) {
    pair<int, int> P;
    P = q.top();
    int c = P.second;
    q.pop();
    for (int i = 0; i < G[c].size(); i++) {
      if (dis[s][G[c][i].to] > dis[s][c] + G[c][i].cost) {
        dis[s][G[c][i].to] = dis[s][c] + G[c][i].cost;
        q.push(pair<int, int>(dis[s][G[c][i].to], G[c][i].to));
      }
    }
  }
};
int main() {
  int n, m, k;
  while (cin >> n >> m >> k) {
    for (int i = 0; i < m; i++) {
      int a, b, c;
      cin >> a >> b >> c;
      edge e;
      e.to = b;
      e.cost = c;
      G[a].push_back(e);
      e.to = a;
      G[b].push_back(e);
      data o;
      o.from = a;
      o.to = b;
      go[i] = o;
    }
    for (int i = 0; i < k; i++) {
      int a, b;
      cin >> a >> b;
      res[i] = (pair<int, int>(a, b));
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        dis[i][j] = 1000000000;
      }
    }
    for (int i = 1; i <= n; i++) {
      dfs(i);
    }
    int ans = 1000000000;
    for (int j = 0; j < m; j++) {
      int sum = 0;
      for (int i = 0; i < k; i++) {
        int u;
        u = min(dis[res[i].first][go[j].to] + dis[res[i].second][go[j].from],
                dis[res[i].first][go[j].from] + dis[res[i].second][go[j].to]);
        u = min(u, dis[res[i].first][res[i].second]);
        sum = sum + u;
      }
      ans = min(ans, sum);
    }
    cout << ans << "\n";
  }
}
