func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<int> graph[123490];   bool attacked[123490], visited[123490];   int n, m, parent[123490];   int dist, last;   void dfs(int u, int depth) {     if (attacked[u]) {       if (dist < depth) {         dist = depth;         last = u;       } else {         if (dist == depth) {           last = min(last, u);         }       }     }     visited[u] = true;     for (int i = (int)0; i <= (int)graph[u].size() - 1; i++) {       int v = graph[u][i];       if (!visited[v]) {         parent[v] = u;         dfs(v, depth + 1);       }     }   }   vector<int> path;   void augment_path(int v) {     visited[v] = true;     path.push_back(v);     if (parent[v] == -1) return;     augment_path(parent[v]);   }   int all = 0;   bool dfs2(int u) {     visited[u] = true;     int ans = 0;     for (int i = (int)0; i <= (int)graph[u].size() - 1; i++) {       int v = graph[u][i];       if (!visited[v]) {         ans |= dfs2(v);       }     }     if (attacked[u]) ans = 1;     all += ans;     return ans;   }   int main() {     cin >> n >> m;     int u, v;     for (int i = (int)1; i <= (int)n - 1; i++) {       cin >> u >> v;       graph[u].push_back(v);       graph[v].push_back(u);     }     int tmp = 123490;     for (int i = (int)1; i <= (int)m; i++) {       cin >> u;       attacked[u] = true;       tmp = min(tmp, u);     }     dist = -1;     dfs(tmp, 0);     tmp = last;     memset(parent, -1, sizeof parent);     memset(visited, 0, sizeof visited);     dist = -1;     dfs(last, 0);     cout << min(tmp, last) << endl;     memset(visited, 0, sizeof visited);     dfs2(tmp);     cout << (all * 2) - 2 - dist << endl;     return 0;   }   