func_code_string: #include <bits/stdc++.h>   std::vector<long long> G[100001];   std::vector<long long> psn[100001];   std::vector<long long> arr[100001][20];   long long par[100001], lvl[100001];   long long P[100001][20];   void dfs_visit(long long s, long long p) {     if (p != -1) {       par[s] = p;       lvl[s] = 1 + lvl[p];     }     for (long long i = 0, j = (long long)G[s].size(); i < j; i++) {       if (G[s][i] != p) dfs_visit(G[s][i], s);     }     return;   }   std::vector<long long> merger(std::vector<long long> left,                                 std::vector<long long> right) {     std::vector<long long> res;     long long n1 = (long long)left.size(), n2 = (long long)right.size();     long long i = 0, j = 0, k = 0;     while (i != n1 && j != n2 && k != 10) {       if (left[i] < right[j]) {         res.push_back(left[i]);         i++;       } else if (left[i] > right[j]) {         res.push_back(right[j]);         j++;       } else {         res.push_back(left[i]);         i++;         j++;       }       k++;     }     while (i != n1 && k != 10) {       res.push_back(left[i]);       i++;       k++;     }     while (j != n2 && k != 10) {       res.push_back(right[j]);       j++;       k++;     }     return res;   }   void ST_build(long long n) {     for (long long i = 1; i <= n; i++) {       for (long long j = 0; (1 << j) <= n; j++) P[i][j] = -1;     }     for (long long i = 1; i <= n; i++) {       P[i][0] = par[i];       arr[i][0] = merger(psn[i], psn[par[i]]);     }     for (long long j = 1; (1 << j) <= n; j++) {       for (long long i = 1; i <= n; i++) {         if (P[i][j - 1] != -1) {           P[i][j] = P[P[i][j - 1]][j - 1];           arr[i][j] = merger(arr[i][j - 1], arr[P[i][j - 1]][j - 1]);         }       }     }     return;   }   std::vector<long long> LCA_find(long long p, long long q) {     std::vector<long long> res = merger(psn[p], psn[q]);     if (lvl[p] < lvl[q]) {       long long tmp = p;       p = q;       q = tmp;     }     long long lx = 0;     for (lx = 1; (1 << lx) <= lvl[p]; lx++)       ;     lx--;     for (long long i = lx; i >= 0; i--) {       if ((lvl[p] - (1 << i)) >= lvl[q]) {         res = merger(res, arr[p][i]);         p = P[p][i];       }     }     if (p == q) return res;     for (long long i = lx; i >= 0; i--) {       if ((P[p][i] != -1) && (P[p][i] != P[q][i])) {         res = merger(res, arr[p][i]);         res = merger(res, arr[q][i]);         p = P[p][i];         q = P[q][i];       }     }     res = merger(res, arr[p][0]);     res = merger(res, arr[q][0]);     return res;   }   int main(void) {     std::ios_base::sync_with_stdio(false);     std::cin.tie(NULL);     std::cout.tie(NULL);     long long n, m, q;     std::cin >> n >> m >> q;     for (long long i = 0; i < n - 1; i++) {       long long s, d;       std::cin >> s >> d;       G[s].push_back(d);       G[d].push_back(s);     }     for (long long i = 1; i <= m; i++) {       long long t;       std::cin >> t;       if ((long long)psn[t].size() < 10) psn[t].push_back(i);     }     dfs_visit(1, -1);     ST_build(n);     while (q--) {       long long v, u, a;       std::cin >> v >> u >> a;       std::vector<long long> ans = LCA_find(v, u);       a = std::min(a, (long long)ans.size());       std::cout << a <<    ;       for (long long i = 0; i < a; i++) std::cout << ans[i] <<    ;       std::cout <<   n ;     }     return 0;   }   