func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<vector<int> > ad(123456);   vector<int> vis(123456, 0), par(123456, -1), hc(123456, 0), hp(123456, 0),       v(123456, 0);   void dfs(int s) {     int i, a, x = ad[s].size(), y = 0;     for (i = 0; i < x; i++) {       a = ad[s][i];       if (vis[a] == 0) par[a] = s, vis[a] = 1, dfs(a);     }     for (i = 0; i < x; i++) {       a = ad[s][i];       if (par[a] == s) {         if (v[a] == 1 || hc[a] > 0) y = max(y, 1 + hc[a]);       }     }     hc[s] = y;     return;   }   void fun(int s) {     int x = ad[s].size(), y = -1, i, a, as, k, ind;     for (i = 0; i < x; i++) {       a = ad[s][i];       if (vis[a] == 0) {         if (hc[a] > y && (hc[a] > 0 || v[a] == 1))           y = hc[a], k = 1, ind = a;         else if ((hc[a] == y && y > 0) || (y == 0 && v[a] == 1))           k++;       }     }     if (y == -1) {       if (hp[s] > 0 || v[s] == 1)         as = hp[s] + 1;       else if (hp[s] == 0)         as = 0;     } else if (y >= 0)       as = max(1 + hp[s], y + 2);     if (as > 0) {       for (i = 0; i < x; i++) {         a = ad[s][i];         if (vis[a] == 0) hp[a] = as;       }     }     if (y >= 0 && k == 1) {       y = -1;       for (i = 0; i < x; i++) {         a = ad[s][i];         if (vis[a] == 0 && a != ind && (hc[a] > 0 || v[a] == 1))           y = max(hc[a], y);       }       if (y == -1) {         if (hp[s] > 0 || v[s] == 1)           hp[ind] = hp[s] + 1;         else if (hp[s] == 0)           hp[ind] = 0;       } else if (y >= 0)         hp[ind] = max(y + 2, hp[s] + 1);     }     for (i = 0; i < x; i++) {       a = ad[s][i];       if (vis[a] == 0) vis[a] = 1, fun(a);     }     return;   }   int trv(int s) {     int x = ad[s].size(), i, y = 0, z, a;     for (i = 0; i < x; i++) {       a = ad[s][i];       if (vis[a] == 0) {         vis[a] = 1, z = trv(a);         if (z > 0 || v[a] == 1) y += (2 + z);       }     }     return y;   }   int main() {     int x, y, n, m, i;     scanf( %d , &n), scanf( %d , &m);     for (i = 1; i < n; i++) {       scanf( %d , &x), scanf( %d , &y);       x--, y--, ad[x].push_back(y), ad[y].push_back(x);     }     for (i = 0; i < m; i++) scanf( %d , &x), x--, v[x] = 1;     vis[0] = 1;     dfs(0);     for (i = 1; i < n; i++) vis[i] = 0;     fun(0);     x = -1, y = -1;     for (i = 0; i < n; i++) {       m = max(hc[i], hp[i]);       if (m > y && v[i]) y = m, x = i;     }     for (i = 0; i < n; i++) vis[i] = 0;     vis[x] = 1;     m = trv(x);     printf( %d n%d n , x + 1, m - y);     return 0;   }   