func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long N = 1e5 + 5, INF = -1e9;   long long down[N], mx[N], up[N], dp[N], sum[N];   unordered_map<long long, vector<long long>> mp[N];   long long n, m, pre[N], suf[N], ans[N];   vector<pair<long long, long long>> adj[N];   bool mark[N];   void dfs_down(long long u, long long par) {     down[u] = up[u] = mark[u] ? 0 : INF;     for (auto x : adj[u]) {       long long v = x.first, w = x.second;       if (v == par) continue;       dfs_down(v, u);       mp[u][down[v] + w].push_back(v);       down[u] = max(down[u], down[v] + w);     }     pre[0] = suf[adj[u].size() - 1] = INF;     for (long long i = 0; i < adj[u].size(); i++) {       long long v = adj[u][i].first, w = adj[u][i].second;       pre[i + 1] = v ^ par ? max(pre[i], down[v] + w) : pre[i];     }     for (long long i = adj[u].size() - 1; i; i--) {       long long v = adj[u][i].first, w = adj[u][i].second;       suf[i - 1] = v ^ par ? max(suf[i], down[v] + w) : suf[i];     }     for (long long i = 0; i < adj[u].size(); i++)       if (adj[u][i].first ^ par) mx[adj[u][i].first] = max(suf[i], pre[i]);   }   void dfs_up(long long u, long long par) {     for (auto x : adj[u]) {       long long v = x.first, w = x.second;       if (v == par) continue;       up[v] = max(up[v], max(up[u], mx[v]) + w);       dfs_up(v, u);     }   }   void dfs1(long long u, long long par) {     if (mark[u] && up[u] > down[u]) dp[u]++;     for (auto x : adj[u]) {       long long v = x.first, w = x.second;       if (v == par) continue;       dfs1(v, u);       ans[u] += dp[v];       if (up[u] > mx[v]) dp[u] += dp[v];       if (up[u] < mx[v]) {         long long sz = mp[u][mx[v]].size();         if (down[v] + w == mx[v]) sz--;         if (sz ^ 1) continue;         for (long long s : mp[u][mx[v]])           if (s ^ v) sum[s] += dp[v];       }     }   }   void dfs2(long long u, long long par) {     if (mark[u] && down[u] > up[u]) sum[u]++;     if (mp[u][down[u]].size() == 1) sum[mp[u][down[u]][0]] += sum[u];     for (auto x : adj[u])       if (x.first ^ par) dfs2(x.first, u);     ans[u] += sum[u];   }   inline void read_input() {     cin >> n >> m;     for (long long i = 0; i < m; i++) {       long long v;       cin >> v;       mark[--v] = true;     }     for (long long i = 1; i < n; i++) {       long long u, v, w;       cin >> u >> v >> w;       adj[--u].push_back({--v, w});       adj[v].push_back({u, w});     }   }   inline void solve() {     dfs_down(0, 0);     dfs_up(0, 0);     dfs1(0, 0);     dfs2(0, 0);   }   inline void write_output() {     long long mx = 0, cnt = 0;     for (long long u = 0; u < n; u++) {       if (mark[u]) continue;       if (mx < ans[u]) {         mx = ans[u];         cnt = 0;       }       if (mx == ans[u]) cnt++;     }     cout << mx <<     << cnt << endl;   }   int32_t main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     read_input(), solve(), write_output();     return 0;   }   