func_code_string: #include <bits/stdc++.h>   using namespace std;   int a[1000000], g[1000000], h[1000000];   int d[1000000];   int dp[1000000];   int up[1000000];   int h1[1000000];   int h2[1000000];   int t1[1000000];   int t2[1000000];   vector<int> v[1000000];   int x, y, n, m;   int maxy, one_kek, two_kek;   void dfs(int x, int pr = -1) {     h[x] = 1;     d[x] = g[x];     h1[x] = 0;     h2[x] = 0;     t1[x] = 0;     t2[x] = 0;     for (int i = 0; i < v[x].size(); i++) {       int to = v[x][i];       if (to == pr) continue;       dfs(to, x);       if (d[to] == 0) continue;       d[x] += d[to];       h[x] += h[to];       if (1 + h1[to] > h2[x]) {         h2[x] = 1 + h1[to];         t2[x] = to;         if (h2[x] > h1[x]) {           swap(h1[x], h2[x]);           swap(t1[x], t2[x]);         }       }     }     if (d[x] == 0) return;   }   void dfs1(int x, int pr = -1) {     if (d[x] == 0) return;     if (pr == -1)       dp[x] = h1[x];     else {       if (t1[pr] == x)         up[x] = 1 + max(up[pr], h2[pr]);       else         up[x] = 1 + max(up[pr], h1[pr]);       dp[x] = max(h1[x], up[x]);     }     for (int i = 0; i < v[x].size(); i++) {       int to = v[x][i];       if (to == pr) continue;       dfs1(to, x);     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n >> m;     for (int i = 1; i < n; i++) {       cin >> x >> y;       v[x].push_back(y);       v[y].push_back(x);     }     for (int i = 1; i <= m; i++) {       cin >> a[i];       g[a[i]]++;     }     if (m == 1) {       cout << a[1] <<   n  << 0;       return 0;     }     dfs(a[1]);     dfs1(a[1]);     for (int i = 1; i <= m; i++) {       if (dp[a[i]] > maxy) {         maxy = dp[a[i]];         one_kek = a[i];       } else if (dp[a[i]] == maxy)         one_kek = min(one_kek, a[i]);     }     cout << one_kek <<   n  << h[a[1]] * 2 - 2 - maxy <<   n ;   }   