func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<int> g[100010];   int t[100010], p[18][100010], L[100010], d[100010];   vector<int> a[18][100010], c[100010];   void dfs(int u) {     for (int i = 0; i < (int)g[u].size(); i++) {       int v = g[u][i];       if (t[v] == -1) {         t[v] = u;         d[v] = d[u] + 1;         dfs(v);       }     }   }   void Merge(const vector<int>& A, const vector<int>& B, vector<int>& C,              int L = 10) {     int i = 0, j = 0, k = 0, n = (int)A.size(), m = (int)B.size();     while (i < n && j < m && k < L) {       if (A[i] < B[j]) {         C.push_back(A[i]);         i++, k++;       } else if (B[j] < A[i]) {         C.push_back(B[j]);         j++, k++;       } else {         C.push_back(A[i]);         i++;         j++;       }     }     while (i < n && k < L) {       C.push_back(A[i]);       i++, k++;     }     while (j < m && k < L) {       C.push_back(B[j]);       j++, k++;     }   }   int scan() {     int ret = 0;     int ip = getchar();     for (; ip <  0  || ip >  9 ; ip = getchar())       ;     for (; ip >=  0  && ip <=  9 ; ip = getchar()) ret = ret * 10 + ip -  0 ;     return ret;   }   int main() {     int n, m, q, i, j, u, v, l, x, y;     vector<int> ans, temp, temp1;     L[1] = 0;     for (i = 2; i < 100010; i++) L[i] = L[i >> 1] + 1;     n = scan();     m = scan();     q = scan();     for (i = 0; i < n - 1; i++) {       u = scan();       v = scan();       --u, --v;       g[u].push_back(v);       g[v].push_back(u);     }     for (i = 0; i < m; i++) {       u = scan();       --u;       c[u].push_back(i + 1);     }     for (i = 0; i < n; i++) t[i] = -1;     t[0] = 0;     d[0] = 0;     dfs(0);     t[0] = -1;     for (i = 0; i < n; i++)       for (j = 0; (1 << j) < n; j++) p[j][i] = -1;     for (i = 0; i < n; i++) {       p[0][i] = t[i];       if (t[i] != -1 && (int)c[t[i]].size() > 0)         for (j = 0; j < (int)c[t[i]].size() && j < 10; j++)           a[0][i].push_back(c[t[i]][j]);     }     for (j = 1; (1 << j) < n; j++) {       for (i = 0; i < n; i++) {         if (p[j - 1][i] != -1) {           p[j][i] = p[j - 1][p[j - 1][i]];           Merge(a[j - 1][i], a[j - 1][p[j - 1][i]], a[j][i]);         }       }     }     while (q--) {       u = scan();       v = scan();       m = scan();       --u, --v;       if (u == v) {         if (!c[u].empty()) {           m = min(m, (int)c[u].size());           printf( %d , m);           for (i = 0; i < m; i++) printf(  %d , c[u][i]);           printf(  n );         } else           printf( 0 n );         continue;       }       x = u;       y = v;       temp.clear();       temp1.clear();       ans.clear();       if (d[u] < d[v]) swap(u, v);       temp = c[u];       temp1 = c[v];       Merge(temp, temp1, ans);       l = L[d[u]];       for (i = l; i >= 0; i--)         if (d[u] - (1 << i) >= d[v]) {           temp = ans;           ans.clear();           Merge(temp, a[i][u], ans, m);           u = p[i][u];         }       if (u != v) {         for (i = l; i >= 0; i--)           if (p[i][u] != -1 && p[i][u] != p[i][v]) {             temp.clear();             Merge(a[i][u], a[i][v], temp, m);             temp1 = ans;             ans.clear();             Merge(temp, temp1, ans, m);             u = p[i][u];             v = p[i][v];           }         temp = ans;         ans.clear();         Merge(temp, a[0][u], ans, m);       }       m = min(m, (int)ans.size());       printf( %d , m);       for (i = 0; i < m; i++) printf(  %d , ans[i]);       printf(  n );     }     return 0;   }   