#include <bits/stdc++.h>
using namespace std;
long long modd = 1000 * 1000 * 1000 + 7;
template <class T>
class Graph {
 public:
  vector<T> vertices;
  vector<set<int>> neighbors;
  vector<bool> visited;
  Graph() {}
  Graph(int n, T default_val = 0) {
    for (int i = 0; i < n; ++i) {
      AddVertex(default_val);
    }
  }
  void AddVertex(T val) {
    vertices.push_back(val);
    neighbors.push_back(set<int>());
  }
  bool EdgeExists(int i, int j) {
    return (neighbors[i].find(j) != neighbors[i].end());
  }
  void AddEdge(int i, int j) {
    if (!EdgeExists(i, j)) {
      neighbors[i].insert(j);
      if (i != j) {
        neighbors[j].insert(i);
      }
    }
  }
  T& operator[](int i) { return vertices[i]; }
  void RemoveEdge(int i, int j) {
    if (EdgeExists(i, j)) {
      neighbors[i].erase(find(neighbors[i].begin(), neighbors[i].end(), j));
      neighbors[j].erase(find(neighbors[j].begin(), neighbors[j].end(), i));
    }
  }
  int vertices_count() { return vertices.size(); }
  void print_() {
    for (int i = (0); i < (0) + (vertices.size()); ++i) {
      for (auto x : neighbors[i]) {
        if (i <= x) {
          cout << i << "-" << x << endl;
        }
      }
    }
  }
};
vector<vector<int>> adj(1001);
template <class T>
pair<vector<T>, vector<int>> DijkstraUndirected(int N_vertices,
                                                vector<vector<int>>& edges,
                                                int s, T infinity) {
  vector<T> dist(N_vertices, infinity);
  dist[s] = 0;
  vector<int> prev(N_vertices);
  set<pair<T, int>> Q;
  for (int i = 0; i < N_vertices; ++i) {
    Q.insert(make_pair(dist[i], i));
  }
  while (!Q.empty()) {
    int u = Q.begin()->second;
    Q.erase(Q.begin());
    for (int v : adj[u]) {
      T one_way = 0, other_way = 0;
      one_way = edges[u][v];
      T alt = dist[u] + one_way + other_way;
      if (alt < dist[v]) {
        prev[v] = u;
        Q.erase(make_pair(dist[v], v));
        dist[v] = alt;
        Q.insert(make_pair(dist[v], v));
      }
    }
  }
  return make_pair(dist, prev);
};
int main() {
  ios_base::sync_with_stdio(false);
  cout.precision(17);
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  uniform_int_distribution<int> rand_gen(0, modd);
  int test_cases = 1;
  for (int t = (1); t < (1) + (test_cases); ++t) {
    vector<vector<int>> edges(1001, vector<int>(1001, modd));
    multiset<pair<int, int>> edges_;
    int n;
    cin >> n;
    int m;
    cin >> m;
    int k;
    cin >> k;
    for (int i = (0); i < (0) + (m); ++i) {
      int x;
      cin >> x;
      int y;
      cin >> y;
      int w;
      cin >> w;
      edges[x - 1][y - 1] = w;
      edges[y - 1][x - 1] = w;
      adj[x - 1].push_back(y - 1);
      adj[y - 1].push_back(x - 1);
      edges_.insert(make_pair(x - 1, y - 1));
    }
    vector<vector<int>> dist(1001, vector<int>(1001));
    for (int i = (0); i < (0) + (n); ++i) {
      auto q = DijkstraUndirected<int>(n, edges, i, modd).first;
      for (int j = (0); j < (0) + (n); ++j) {
        dist[i][j] = q[j];
      }
    }
    vector<pair<int, int>> cour;
    int ret = modd;
    for (int i = (0); i < (0) + (k); ++i) {
      int x;
      cin >> x;
      int y;
      cin >> y;
      --x;
      --y;
      cour.push_back(make_pair(x, y));
    }
    for (auto e : edges_) {
      int dist_sum = 0;
      for (auto c : cour) {
        int d = min(dist[c.first][c.second],
                    min(dist[e.first][c.first], dist[e.second][c.first]) +
                        min(dist[e.first][c.second], dist[e.second][c.second]));
        dist_sum += d;
      }
      ret = min(ret, dist_sum);
    }
    cout << ret << endl;
  }
  return 0;
}
