func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, m, q;   int par[26][100005], depth[100005];   vector<int> st[400005];   vector<int> G[100005];   vector<int> SS[26][100005];   int cnt, chaincnt;   void get10(vector<int> &res, const vector<int> &fir, const vector<int> sec) {     int c1 = 0, c2 = 0;     res = vector<int>(min((int)fir.size() + (int)sec.size(), 10));     for (int i = 0; i < (int)res.size(); i++) {       if (c1 != fir.size() && c2 != sec.size()) {         if (fir[c1] < sec[c2]) {           res[i] = fir[c1++];         } else {           res[i] = sec[c2++];         }       } else if (c1 == fir.size()) {         res[i] = sec[c2++];       } else {         res[i] = fir[c1++];       }     }     return;   }   set<int> ret1, ret2;   int LCA(int u, int v) {     ret1.clear(), ret2.clear();     if (depth[u] < depth[v]) swap(u, v);     int dif = depth[u] - depth[v];     for (int i = 0; i <= 24; i++) {       if (dif & (1 << i)) {         u = par[i][u];       }     }     if (u == v) return u;     for (int i = 24; i >= 0; i--) {       if (par[i][u] != par[i][v]) {         u = par[i][u], v = par[i][v];       }     }     return par[0][u];   }   vector<int> solve(int u, int v) {     int lca = LCA(u, v);     int d1 = depth[u] - depth[lca] + 1;     int d2 = depth[v] - depth[lca] + 1;     int lvl = 26;     set<int> ret1;     while (d1 > 0) {       if ((1 << lvl) <= d1) {         d1 -= (1 << lvl);         for (int i = 0; i < (int)SS[lvl][u].size() && i < 10; i++) {           ret1.insert(SS[lvl][u][i]);         }         while (ret1.size() > 10) {           ret1.erase(--ret1.end());         }         u = par[lvl][u];       }       lvl--;       if (lvl < 0) lvl = 0;     }     lvl = 26;     set<int> ret2;     while (d2 > 0) {       if ((1 << lvl) <= d2) {         d2 -= (1 << lvl);         for (int i = 0; i < (int)SS[lvl][v].size() && i < 10; i++) {           ret2.insert(SS[lvl][v][i]);         }         while (ret2.size() > 10) {           ret2.erase(--ret2.end());         }         v = par[lvl][v];       }       lvl--;       if (lvl < 0) lvl = 0;     }     ret1.insert(ret2.begin(), ret2.end());     while (ret1.size() > 10) {       ret1.erase(--ret1.end());     }     vector<int> ret(ret1.begin(), ret1.end());     return ret;   }   void dfs(int u, int p, int dep) {     depth[u] = dep;     par[0][u] = p;     for (int i = 0; i < (int)G[u].size(); i++) {       int v = G[u][i];       if (v == p) continue;       dfs(v, u, dep + 1);     }   }   int main() {     int from, to;     scanf( %d %d %d , &n, &m, &q);     for (int i = 1; i < n; i++) {       scanf( %d %d , &from, &to);       G[from].push_back(to);       G[to].push_back(from);     }     int cur;     for (int i = 1; i <= m; i++) {       scanf( %d , &cur);       SS[0][cur].push_back(i);     }     memset(par, -1, sizeof par);     chaincnt = cnt = 1;     dfs(1, -1, 0);     for (int i = 1; i <= 24; i++)       for (int j = 1; j <= n; j++)         if (par[i - 1][j] != -1) {           par[i][j] = par[i - 1][par[i - 1][j]];           get10(SS[i][j], SS[i - 1][par[i - 1][j]], SS[i - 1][j]);         }     int how;     vector<int> ans;     while (q--) {       scanf( %d %d %d , &from, &to, &how);       ans = solve(from, to);       printf( %d , min((int)ans.size(), how));       for (int i = 0; i < ans.size() && how; i++, how--) {         printf(  %d , ans[i]);       }       printf(  n );     }     return 0;   }   