func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     long long n, m;     cin >> n >> m;     vector<vector<long long>> dist((size_t)n,                                    vector<long long>((size_t)n, (long long)1e16));     for (long long i = 0; i < n; i++) {       dist[i][i] = (long long)0;     }     for (long long i = 0; i < m; i++) {       long long u, v;       cin >> u >> v;       u--, v--;       dist[u][v] = dist[v][u] = 0;     }     for (long long k = 0; k < n; k++) {       for (long long i = 0; i < n; i++) {         for (long long j = 0; j < n; j++) {           dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);         }       }     }     long long s, b, k, h;     cin >> s >> b >> k >> h;     vector<pair<long long, pair<long long, long long>>> x((size_t)s);     for (long long i = 0; i < s; i++) {       cin >> x[i].first >> x[i].second.first >> x[i].second.second;       x[i].first--;     }     vector<pair<long long, long long>> y((size_t)b);     for (long long i = 0; i < b; i++) {       cin >> y[i].first >> y[i].second;       y[i].first--;     }     vector<vector<long long>> adj((size_t)s);     for (long long i = 0; i < s; i++) {       for (long long j = 0; j < b; j++) {         if (x[i].second.first >= y[j].second &&             x[i].second.second >= dist[x[i].first][y[j].first]) {           adj[i].push_back(j);         }       }     }     vector<bool> visited;     vector<long long> matching((size_t)b, -1);     function<bool(long long)> visit = [&](long long i) {       if (visited[i]) {         return false;       }       visited[i] = true;       for (long long j : adj[i]) {         if (matching[j] == -1 || visit(matching[j])) {           matching[j] = i;           return true;         }       }       return false;     };     long long f = 0;     for (long long i = 0; i < s; i++) {       visited.assign((size_t)s, false);       if (visit(i)) {         f++;       }     }     cout << min(f * k, h * s) << endl;     return 0;   }   