//IOI 2021
//this will accept, By the order of the peaky fucking blinders
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define ff first
#define ss second

typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = 100 * 1000 + 17, LG = 20, inf = 2e9 + 17;

struct node {
	vector<int> ppl;
	friend void mrge(node &x, const node &y, const node &z) {
		merge(y.ppl.begin(), y.ppl.end(), z.ppl.begin(), z.ppl.end(), back_inserter(x.ppl));
		x.ppl.resize(unique(x.ppl.begin(), x.ppl.end()) - x.ppl.begin());
		if (x.ppl.size() > 10)
			x.ppl.resize(10);
	}
} tmp;

int n, m, q, tin[MAXN], tout[MAXN], up[MAXN][LG], timer, sub[MAXN], part[MAXN], part_num, num[MAXN], pr[MAXN];
vector<int> adj[MAXN], pl[MAXN], decomp[MAXN];
vector<node> seg[MAXN];

void heavy_light(int v = 1, int par = 0) {
	int cnt;
	if (sub[v] < sub[par] / 2 || v == 1)
		cnt = ++part_num;
	else
		cnt = part[par];
	part[v] = cnt;
	num[v] = decomp[cnt].size();
	decomp[cnt].pb(v);
	for (auto i : adj[v])
		if (i != par)
			heavy_light(i, v);

}

void dfs(int v = 1, int par = 0) {
	pr[v] = par;
	tin[v] = timer++;
	up[v][0] = par;
	for (int i = 1; i < LG; i++)
		up[v][i] = up[up[v][i - 1]][i - 1];
	for (auto i : adj[v])
		if (i != par)
			dfs(i, v), sub[v] += sub[i];
	sub[v]++;
	tout[v] = timer++;
}

bool is_anc(int v, int u) {
	return tin[v] <= tin[u] && tout[u] <= tout[v];
}

int lca(int v, int u) {
	if (is_anc(u, v))
		return u;
	for (int i = LG - 1; i >= 0; i--)
		if (!is_anc(up[u][i], v))
			u = up[u][i];
	return up[u][0];
}

void build(int x, int v, int l, int r) {
	if (l + 1 == r) {
		for (auto i : pl[decomp[x][l]])
			seg[x][v].ppl.pb(i);
		return;
	}
	build(x, v << 1, l, l + r >> 1);
	build(x, v << 1 | 1, l + r >> 1, r);
	mrge(seg[x][v], seg[x][v << 1], seg[x][v << 1 | 1]);
}

void get(int x, int lp, int rp, int v, int l, int r, node &ans) {
	if (rp <= l || r <= lp)
		return;
	if (lp <= l && r <= rp) {
		tmp = ans;
		ans.ppl.clear();
		mrge(ans, tmp, seg[x][v]);
		return;
	}
	get(x, lp, rp, v << 1, l, l + r >> 1, ans);
	get(x, lp, rp, v << 1 | 1, l + r >> 1, r, ans);
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	tout[0] = inf;
	cin >> n >> m >> q;
	for (int i = 1; i < n; i++) {
		int v, u;
		cin >> v >> u;
		adj[v].pb(u);
		adj[u].pb(v);
	}
	int t;
	for (int i = 1; i <= m; i++)
		cin >> t, pl[t].pb(i);
	for (int i = 1; i <= n; i++) {
		sort(pl[i].begin(), pl[i].end());
		if (pl[i].size() > 10)
			pl[i].resize(10);
	}
	dfs();
	heavy_light();
	for (int i = 1; i <= part_num; i++) {
		seg[i].resize(decomp[i].size() << 2);
		build(i, 1, 0, decomp[i].size());
	}
	while (q--) {
		int v, u, a;
		cin >> v >> u >> a;
		int lc = lca(v, u);
		node ans;
		while (!is_anc(v, lc)) {
			if (is_anc(lc, pr[decomp[part[v]][0]]))
				get(part[v], 0, num[v] + 1, 1, 0, decomp[part[v]].size(), ans);
			else
				get(part[v], num[lc], num[v] + 1, 1, 0, decomp[part[v]].size(), ans);
			v = pr[decomp[part[v]][0]];
		}
		v = u;
		while (!is_anc(v, lc)) {
			if (is_anc(lc, pr[decomp[part[v]][0]]))
				get(part[v], 0, num[v] + 1, 1, 0, decomp[part[v]].size(), ans);
			else
				get(part[v], num[lc], num[v] + 1, 1, 0, decomp[part[v]].size(), ans);
			v = pr[decomp[part[v]][0]];
		}
		get(part[lc], num[lc], num[lc] + 1, 1, 0, decomp[part[lc]].size(), ans);
		ans.ppl.resize(unique(ans.ppl.begin(), ans.ppl.end()) - ans.ppl.begin());
		if (ans.ppl.size() > a)
			ans.ppl.resize(a);
		cout << ans.ppl.size();
		for (auto i : ans.ppl)
			cout << ' ' << i;
		cout << endl;

	}
	return 0;
}


//IOI 2021
//this will accept, By the order of the peaky fucking blinders
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define ff first
#define ss second

typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = 100 * 1000 + 17, LG = 20, inf = 2e9 + 17;

struct node {
	vector<int> ppl;
	friend void mrge(node &x, const node &y, const node &z) {
		merge(y.ppl.begin(), y.ppl.end(), z.ppl.begin(), z.ppl.end(), back_inserter(x.ppl));
		x.ppl.resize(unique(x.ppl.begin(), x.ppl.end()) - x.ppl.begin());
		if (x.ppl.size() > 10)
			x.ppl.resize(10);
	}
} tmp;

int n, m, q, tin[MAXN], tout[MAXN], up[MAXN][LG], timer, sub[MAXN], part[MAXN], part_num, num[MAXN], pr[MAXN];
vector<int> adj[MAXN], pl[MAXN], decomp[MAXN];
vector<node> seg[MAXN];

void heavy_light(int v = 1, int par = 0) {
	int cnt;
	if (sub[v] < (sub[par] + 1) / 2 || v == 1)
		cnt = ++part_num;
	else
		cnt = part[par];
	part[v] = cnt;
	num[v] = decomp[cnt].size();
	decomp[cnt].pb(v);
	for (auto i : adj[v])
		if (i != par)
			heavy_light(i, v);

}

void dfs(int v = 1, int par = 0) {
	pr[v] = par;
	tin[v] = timer++;
	up[v][0] = par;
	for (int i = 1; i < LG; i++)
		up[v][i] = up[up[v][i - 1]][i - 1];
	for (auto i : adj[v])
		if (i != par)
			dfs(i, v), sub[v] += sub[i];
	sub[v]++;
	tout[v] = timer++;
}

bool is_anc(int v, int u) {
	return tin[v] <= tin[u] && tout[u] <= tout[v];
}

int lca(int v, int u) {
	if (is_anc(u, v))
		return u;
	for (int i = LG - 1; i >= 0; i--)
		if (!is_anc(up[u][i], v))
			u = up[u][i];
	return up[u][0];
}

void build(int x, int v, int l, int r) {
	if (l + 1 == r) {
		for (auto i : pl[decomp[x][l]])
			seg[x][v].ppl.pb(i);
		return;
	}
	build(x, v << 1, l, l + r >> 1);
	build(x, v << 1 | 1, l + r >> 1, r);
	mrge(seg[x][v], seg[x][v << 1], seg[x][v << 1 | 1]);
}

void get(int x, int lp, int rp, int v, int l, int r, node &ans) {
	if (rp <= l || r <= lp)
		return;
	if (lp <= l && r <= rp) {
		tmp = ans;
		ans.ppl.clear();
		mrge(ans, tmp, seg[x][v]);
		return;
	}
	get(x, lp, rp, v << 1, l, l + r >> 1, ans);
	get(x, lp, rp, v << 1 | 1, l + r >> 1, r, ans);
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	tout[0] = inf;
	cin >> n >> m >> q;
	for (int i = 1; i < n; i++) {
		int v, u;
		cin >> v >> u;
		adj[v].pb(u);
		adj[u].pb(v);
	}
	int t;
	for (int i = 1; i <= m; i++)
		cin >> t, pl[t].pb(i);
	for (int i = 1; i <= n; i++) {
		sort(pl[i].begin(), pl[i].end());
		if (pl[i].size() > 10)
			pl[i].resize(10);
	}
	dfs();
	heavy_light();
	for (int i = 1; i <= part_num; i++) {
		seg[i].resize(decomp[i].size() << 2);
		build(i, 1, 0, decomp[i].size());
	}
	while (q--) {
		int v, u, a;
		cin >> v >> u >> a;
		int lc = lca(v, u);
		node ans;
		while (!is_anc(v, lc)) {
			if (is_anc(lc, pr[decomp[part[v]][0]]))
				get(part[v], 0, num[v] + 1, 1, 0, decomp[part[v]].size(), ans);
			else
				get(part[v], num[lc], num[v] + 1, 1, 0, decomp[part[v]].size(), ans);
			v = pr[decomp[part[v]][0]];
		}
		v = u;
		while (!is_anc(v, lc)) {
			if (is_anc(lc, pr[decomp[part[v]][0]]))
				get(part[v], 0, num[v] + 1, 1, 0, decomp[part[v]].size(), ans);
			else
				get(part[v], num[lc], num[v] + 1, 1, 0, decomp[part[v]].size(), ans);
			v = pr[decomp[part[v]][0]];
		}
		get(part[lc], num[lc], num[lc] + 1, 1, 0, decomp[part[lc]].size(), ans);
		ans.ppl.resize(unique(ans.ppl.begin(), ans.ppl.end()) - ans.ppl.begin());
		if (ans.ppl.size() > a)
			ans.ppl.resize(a);
		cout << ans.ppl.size();
		for (auto i : ans.ppl)
			cout << ' ' << i;
		cout << '\n';

	}
	return 0;
}


//IOI 2021
//this will accept, By the order of the peaky fucking blinders
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define ff first
#define ss second

typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = 100 * 1000 + 17, LG = 20, inf = 2e9 + 17;

struct node {
	vector<int> ppl;
	friend void mrge(node &x, const node &y, const node &z) {
		merge(y.ppl.begin(), y.ppl.end(), z.ppl.begin(), z.ppl.end(), back_inserter(x.ppl));
		x.ppl.resize(unique(x.ppl.begin(), x.ppl.end()) - x.ppl.begin());
		if (x.ppl.size() > 10)
			x.ppl.resize(10);
	}
} tmp;

int n, m, q, tin[MAXN], tout[MAXN], up[MAXN][LG], timer, sub[MAXN], part[MAXN], part_num, num[MAXN], pr[MAXN];
vector<int> adj[MAXN], pl[MAXN], decomp[MAXN];
vector<node> seg[MAXN];

void heavy_light(int v = 1, int par = 0) {
	int cnt;
	if (sub[v] < (sub[par] + 1) / 2 || v == 1)
		cnt = ++part_num;
	else
		cnt = part[par];
	part[v] = cnt;
	num[v] = decomp[cnt].size();
	decomp[cnt].pb(v);
	for (auto i : adj[v])
		if (i != par)
			heavy_light(i, v);

}

void dfs(int v = 1, int par = 0) {
	pr[v] = par;
	tin[v] = timer++;
	up[v][0] = par;
	for (int i = 1; i < LG; i++)
		up[v][i] = up[up[v][i - 1]][i - 1];
	for (auto i : adj[v])
		if (i != par)
			dfs(i, v), sub[v] += sub[i];
	sub[v]++;
	tout[v] = timer++;
}

bool is_anc(int v, int u) {
	return tin[v] <= tin[u] && tout[u] <= tout[v];
}

int lca(int v, int u) {
	if (is_anc(u, v))
		return u;
	for (int i = LG - 1; i >= 0; i--)
		if (!is_anc(up[u][i], v))
			u = up[u][i];
	return up[u][0];
}

void build(int x, int v, int l, int r) {
	if (l + 1 == r) {
		for (auto i : pl[decomp[x][l]])
			seg[x][v].ppl.pb(i);
		return;
	}
	build(x, v << 1, l, l + r >> 1);
	build(x, v << 1 | 1, l + r >> 1, r);
	mrge(seg[x][v], seg[x][v << 1], seg[x][v << 1 | 1]);
}

void get(int x, int lp, int rp, int v, int l, int r, node &ans) {
	if (rp <= l || r <= lp)
		return;
	if (lp <= l && r <= rp) {
		tmp = ans;
		ans.ppl.clear();
		mrge(ans, tmp, seg[x][v]);
		return;
	}
	get(x, lp, rp, v << 1, l, l + r >> 1, ans);
	get(x, lp, rp, v << 1 | 1, l + r >> 1, r, ans);
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	tout[0] = inf;
	cin >> n >> m >> q;
	for (int i = 1; i < n; i++) {
		int v, u;
		cin >> v >> u;
		adj[v].pb(u);
		adj[u].pb(v);
	}
	int t;
	for (int i = 1; i <= m; i++)
		cin >> t, pl[t].pb(i);
	for (int i = 1; i <= n; i++) {
		sort(pl[i].begin(), pl[i].end());
		if (pl[i].size() > 10)
			pl[i].resize(10);
	}
	dfs();
	heavy_light();
	for (int i = 1; i <= part_num; i++) {
		seg[i].resize(decomp[i].size() << 2);
		build(i, 1, 0, decomp[i].size());
	}
	while (q--) {
		int v, u, a;
		cin >> v >> u >> a;
		int lc = lca(v, u);
		node ans;
		while (!is_anc(v, lc)) {
			if (is_anc(lc, pr[decomp[part[v]][0]]))
				get(part[v], 0, num[v] + 1, 1, 0, decomp[part[v]].size(), ans);
			else
				get(part[v], num[lc], num[v] + 1, 1, 0, decomp[part[v]].size(), ans);
			v = pr[decomp[part[v]][0]];
		}
		v = u;
		while (!is_anc(v, lc)) {
			if (is_anc(lc, pr[decomp[part[v]][0]]))
				get(part[v], 0, num[v] + 1, 1, 0, decomp[part[v]].size(), ans);
			else
				get(part[v], num[lc], num[v] + 1, 1, 0, decomp[part[v]].size(), ans);
			v = pr[decomp[part[v]][0]];
		}
		get(part[lc], num[lc], num[lc] + 1, 1, 0, decomp[part[lc]].size(), ans);
		ans.ppl.resize(unique(ans.ppl.begin(), ans.ppl.end()) - ans.ppl.begin());
		if (ans.ppl.size() > a)
			ans.ppl.resize(a);
		cout << ans.ppl.size();
		for (auto i : ans.ppl)
			cout << ' ' << i;
		cout << endl;

	}
	return 0;
}


#include <bits/stdc++.h>

#define fi first
#define se second
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define el '\n'

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int N = 1e5 + 10, M = 18, MX = 200;

int n, m, q;
vector<int> adj[N];

int tin[N], tout[N], timer;
int up[N][M];
vector<int> city[N], t[8 * N]; //[M];

int ar[2 * N];

vector<int> gabung(const vector<int>& va, const vector<int>& vb){
    vector<int> temp(va.size() + vb.size());
    merge(va.begin(), va.end(), vb.begin(), vb.end(), temp.begin());
    vector<int> ret;
    int len = temp.size();
    for (int i=0;i<len;i++){
        if (i == 0){
            ret.pb(temp[i]);
        } else{
            if (!ret.empty() && temp[i] == ret.back()) ret.pop_back();
            else if (temp[i] != temp[i - 1]) ret.pb(temp[i]);
        }
    }
    while ((int)ret.size() > MX) ret.pop_back();
    return ret;
}

void build(int v, int tl, int tr){
    if (tl == tr){
        t[v] = city[ar[tl]];
        return;
    }
    int tm = (tl + tr) / 2;
    build(v * 2, tl, tm);
    build(v * 2 + 1, tm + 1, tr);
    t[v] = gabung(t[v * 2], t[v * 2 + 1]);
}

vector<int> ask(int v, int tl, int tr, int l, int r){
    vector<int> ret;
    if (l > r) return ret;
    else if (l <= tl && tr <= r){
        return t[v];
    }
    int tm = (tl + tr) / 2;
    return gabung(ask(v * 2, tl, tm, l, min(tm, r)), ask(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r));
}

void dfs_init(int node, int p){
    tin[node] = ++timer;
    ar[timer] = node;
    up[node][0] = p;
    for (int i=1;i<M;i++){
        int mid = up[node][i - 1];
        up[node][i] = up[mid][i - 1];
    }

    for (auto x : adj[node]){
        if (x == p) continue;
        dfs_init(x, node);
    }
    tout[node] = ++timer;
    ar[timer] = node;
}

bool is_ancestor(int a, int b){
    return tin[a] <= tin[b] && tout[b] <= tout[a];
}

int LCA(int a, int b){
    if (!is_ancestor(a, b) && !is_ancestor(b, a)){
        for (int i=M - 1;i>=0;i--){
            int na = up[a][i];
            if (!is_ancestor(na, b)){
                a = na;
            }
        }
        a = up[a][0];
    }
    if (is_ancestor(b, a)) swap(a, b);
    assert(is_ancestor(a, b));
    return a;
}

void solve(int a, int b, int k){
    int lca = LCA(a, b);
    vector<int> temp1, temp2;
    temp1 = ask(1, 1, timer, tin[lca], tin[a]);
    temp2 = ask(1, 1, timer, tin[lca], tin[b]);
    set<int> setdah;
    for (auto x : temp1) setdah.insert(x);
    for (auto x : temp2) setdah.insert(x);
    k = min(k, (int)setdah.size());
    cout << k << " ";
    for (auto x : setdah){
        if (k-- > 0){
            cout << x << " ";
        }
    }
    cout << el;
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m >> q;
    for (int i=1;i<n;i++){
        int a, b;
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    for (int i=1;i<=m;i++){
        int a;
        cin >> a;
        if ((int)city[a].size() < 10) city[a].pb(i);
    }
    dfs_init(1, 1);
    build(1, 1, timer);
    while (q--){
        int v, u, a;
        cin >> v >> u >> a;
        solve(v, u, a);
    }

    return 0;
}


#include <bits/stdc++.h>

#define fi first
#define se second
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define el '\n'

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int N = 1e5 + 10, M = 18, MX = 100;

int n, m, q;
vector<int> adj[N];

int tin[N], tout[N], timer;
int up[N][M];
vector<int> city[N], t[8 * N]; //[M];

int ar[2 * N];

vector<int> gabung(const vector<int>& va, const vector<int>& vb){
    vector<int> temp(va.size() + vb.size());
    merge(va.begin(), va.end(), vb.begin(), vb.end(), temp.begin());
    vector<int> ret;
    int len = temp.size();
    for (int i=0;i<len;i++){
        if (i == 0){
            ret.pb(temp[i]);
        } else{
            if (!ret.empty() && temp[i] == ret.back()) ret.pop_back();
            else if (temp[i] != temp[i - 1]) ret.pb(temp[i]);
        }
    }
    while ((int)ret.size() > MX) ret.pop_back();
    return ret;
}

void build(int v, int tl, int tr){
    if (tl == tr){
        t[v] = city[ar[tl]];
        return;
    }
    int tm = (tl + tr) / 2;
    build(v * 2, tl, tm);
    build(v * 2 + 1, tm + 1, tr);
    t[v] = gabung(t[v * 2], t[v * 2 + 1]);
}

vector<int> ask(int v, int tl, int tr, int l, int r){
    vector<int> ret;
    if (l > r) return ret;
    else if (l <= tl && tr <= r){
        return t[v];
    }
    int tm = (tl + tr) / 2;
    return gabung(ask(v * 2, tl, tm, l, min(tm, r)), ask(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r));
}

void dfs_init(int node, int p){
    tin[node] = ++timer;
    ar[timer] = node;
    up[node][0] = p;
    for (int i=1;i<M;i++){
        int mid = up[node][i - 1];
        up[node][i] = up[mid][i - 1];
    }

    for (auto x : adj[node]){
        if (x == p) continue;
        dfs_init(x, node);
    }
    tout[node] = ++timer;
    ar[timer] = node;
}

bool is_ancestor(int a, int b){
    return tin[a] <= tin[b] && tout[b] <= tout[a];
}

int LCA(int a, int b){
    if (!is_ancestor(a, b) && !is_ancestor(b, a)){
        for (int i=M - 1;i>=0;i--){
            int na = up[a][i];
            if (!is_ancestor(na, b)){
                a = na;
            }
        }
        a = up[a][0];
    }
    if (is_ancestor(b, a)) swap(a, b);
    assert(is_ancestor(a, b));
    return a;
}

void solve(int a, int b, int k){
    int lca = LCA(a, b);
    vector<int> temp1, temp2;
    temp1 = ask(1, 1, timer, tin[lca], tin[a]);
    temp2 = ask(1, 1, timer, tin[lca], tin[b]);
    set<int> setdah;
    for (auto x : temp1) setdah.insert(x);
    for (auto x : temp2) setdah.insert(x);
    k = min(k, (int)setdah.size());
    cout << k << " ";
    for (auto x : setdah){
        if (k-- > 0){
            cout << x << " ";
        }
    }
    cout << el;
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m >> q;
    for (int i=1;i<n;i++){
        int a, b;
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    for (int i=1;i<=m;i++){
        int a;
        cin >> a;
        if ((int)city[a].size() < 10) city[a].pb(i);
    }
    dfs_init(1, 1);
    build(1, 1, timer);
    while (q--){
        int v, u, a;
        cin >> v >> u >> a;
        solve(v, u, a);
    }

    return 0;
}


#include <bits/stdc++.h>

#define fi first
#define se second
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define el '\n'

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int N = 1e5 + 10, M = 18;

int n, m, q;
vector<int> adj[N];

int tin[N], tout[N], timer;
int up[N][M];
vector<int> city[N], t[8 * N]; //[M];

int ar[2 * N];

vector<int> gabung(const vector<int>& va, const vector<int>& vb){
    vector<int> temp(va.size() + vb.size());
    merge(va.begin(), va.end(), vb.begin(), vb.end(), temp.begin());
    vector<int> ret;
    int len = temp.size();
    for (int i=0;i<len;i++){
        if (i == 0){
            ret.pb(temp[i]);
        } else{
            if (!ret.empty() && temp[i] == ret.back()) ret.pop_back();
            else if (temp[i] != temp[i - 1]) ret.pb(temp[i]);
        }
    }
    while ((int)ret.size() > 10) ret.pop_back();
    return ret;
}

void build(int v, int tl, int tr){
    if (tl == tr){
        t[v] = city[ar[tl]];
        return;
    }
    int tm = (tl + tr) / 2;
    build(v * 2, tl, tm);
    build(v * 2 + 1, tm + 1, tr);
    t[v] = gabung(t[v * 2], t[v * 2 + 1]);
}

vector<int> ask(int v, int tl, int tr, int l, int r){
    vector<int> ret;
    if (l > r) return ret;
    else if (l <= tl && tr <= r){
        return t[v];
    }
    int tm = (tl + tr) / 2;
    return gabung(ask(v * 2, tl, tm, l, min(tm, r)), ask(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r));
}

void dfs_init(int node, int p){
    tin[node] = ++timer;
    ar[timer] = node;
    up[node][0] = p;
    for (int i=1;i<M;i++){
        int mid = up[node][i - 1];
        up[node][i] = up[mid][i - 1];
    }

    for (auto x : adj[node]){
        if (x == p) continue;
        dfs_init(x, node);
    }
    tout[node] = ++timer;
    ar[timer] = node;
}

bool is_ancestor(int a, int b){
    return tin[a] <= tin[b] && tout[b] <= tout[a];
}

int LCA(int a, int b){
    set<int> ans;
    if (!is_ancestor(a, b) && !is_ancestor(b, a)){
        for (int i=M - 1;i>=0;i--){
            int na = up[a][i];
            if (!is_ancestor(na, b)){
                a = na;
            }
        }
        a = up[a][0];
    }
    if (is_ancestor(b, a)) swap(a, b);
    assert(is_ancestor(a, b));
    return a;
}

void solve(int a, int b, int k){
    int lca = LCA(a, b);
    vector<int> temp1, temp2;
    temp1 = ask(1, 1, timer, tin[lca], tin[a]);
    temp2 = ask(1, 1, timer, tin[lca], tin[b]);
    set<int> setdah;
    for (auto x : temp1) setdah.insert(x);
    for (auto x : temp2) setdah.insert(x);
    k = min(k, (int)setdah.size());
    cout << k << " ";
    for (auto x : setdah){
        if (k-- > 0){
            cout << x << " ";
        }
    }
    cout << el;
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m >> q;
    for (int i=1;i<n;i++){
        int a, b;
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    for (int i=1;i<=m;i++){
        int a;
        cin >> a;
        if ((int)city[a].size() < 10) city[a].pb(i);
    }
    dfs_init(1, 1);
    build(1, 1, timer);
    while (q--){
        int v, u, a;
        cin >> v >> u >> a;
        solve(v, u, a);
    }

    return 0;
}


#include <bits/stdc++.h>

#define fi first
#define se second
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define el '\n'

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int N = 1e5 + 10;
const int INF = 1e9;

int n, m, q;
vector<int> adj[N];
vector<int> city[N]; // ids of population

int parent[N], dep[N];
int heavy[N], head[N], pos[N], cur_pos;
int tin[N], timer;
vector<int> path, epath;
int pathlen, epathlen;

int tlca[8 * N];
vector<int> t[8 * N];

void buildlca(int v, int tl, int tr){
    if (tl == tr){
        tlca[v] = epath[tl];
        return;
    }
    int tm = (tl + tr) / 2;
    buildlca(v * 2, tl, tm);
    buildlca(v * 2 + 1, tm + 1, tr);
    if (dep[tlca[v * 2]] < dep[tlca[v * 2 + 1]])
        tlca[v] = tlca[v * 2];
    else
        tlca[v] = tlca[v * 2 + 1];
}
int asklca(int v, int tl, int tr, int l, int r){
    if (l > r) return 0;
    else if (l <= tl && tr <= r){
        return tlca[v];
    }
    int tm = (tl + tr) / 2;
    int temp1 = asklca(v * 2, tl, tm, l, min(tm, r));
    int temp2 = asklca(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r);
    if (dep[temp1] < dep[temp2]) return temp1;
    return temp2;
}

int LCA(int a, int b){
    if (tin[a] > tin[b]) swap(a, b);
    return asklca(1, 0, epathlen - 1, tin[a], tin[b]);
}

void build(int v, int tl, int tr){
    if (tl == tr){
        for (auto x : city[path[tl]]){
            t[v].pb(x);
        }
        return;
    }
    int tm = (tl + tr) / 2;
    build(v * 2, tl, tm);
    build(v * 2 + 1, tm + 1, tr);
    t[v].resize(t[v * 2].size() + t[v * 2 + 1].size());
    merge(t[v * 2].begin(), t[v * 2].end(), t[v * 2 + 1].begin(), t[v * 2 + 1].end(), t[v].begin());
    while (t[v].size() > 10) t[v].pop_back();
}
vector<int> ask(int v, int tl, int tr, int l, int r){
    vector<int> ret;
    if (l > r) return ret;
    else if (l <= tl && tr <= r){
        return t[v];
    }
    int tm = (tl + tr) / 2;
    vector<int> temp1, temp2;
    temp1 = ask(v * 2, tl, tm, l, min(tm, r));
    temp2 = ask(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r);
    ret.resize(temp1.size() + temp2.size());
    merge(temp1.begin(), temp1.end(), temp2.begin(), temp2.end(), ret.begin());
    while (ret.size() > 10) ret.pop_back();
    return ret;
}
vector<int> query(int a, int b){
    vector<int> ret, nret, temp;
    for (; head[a] != head[b]; b = parent[head[b]]){
        if (dep[a] > dep[b]) swap(a, b);
        temp = ask(1, 0, pathlen - 1, pos[head[b]], pos[b]);
        nret.resize(ret.size() + temp.size());
        merge(ret.begin(), ret.end(), temp.begin(), temp.end(), nret.begin());
        while (nret.size() > 10) nret.pop_back();
        ret = nret;
    }
    if (dep[a] > dep[b]) swap(a, b);
    temp = ask(1, 0, pathlen - 1, pos[a], pos[b]);
    nret.resize(ret.size() + temp.size());
    merge(ret.begin(), ret.end(), temp.begin(), temp.end(), nret.begin());
    while (nret.size() > 10) nret.pop_back();
    ret = nret;
    return ret;
}

void dfs_euler(int node){
    epath.pb(node);
    tin[node] = timer++;
    for (auto x : adj[node]){
        if (x == parent[node]) continue;
        dfs_euler(x);
        epath.pb(node);
        timer++;
    }
}

int dfs_init(int node, int p){
    if (node != 1) dep[node] = dep[p] + 1;
    parent[node] = p;

    int ret = 1, mx = 0;
    for (auto x : adj[node]){
        if (x == p) continue;
        int cur = dfs_init(x, node);
        ret += cur;
        if (mx < cur){
            heavy[node] = x;
            mx = cur;
        }
    }
    return ret;
}

void decompose(int node, int h){
    head[node] = h;
    pos[node] = cur_pos++;
    path.pb(node);
    if (heavy[node]){
        decompose(heavy[node], h);
    }
    for (auto x : adj[node]){
        if (x == parent[node] || x == heavy[node]) continue;
        decompose(x, x);
    }
}

void init(){
    int dummy = dfs_init(1, 1);
    dfs_euler(1);
    decompose(1, 1);
    dep[0] = INF;
    pathlen = path.size();
    epathlen = epath.size();

    buildlca(1, 0, epathlen - 1);
    build(1, 0, pathlen - 1);
}

void solve(int v, int u, int a){
    int lca = LCA(v, u);
    vector<int> temp1, temp2;
    temp1 = query(lca, v);
    temp2 = query(lca, u);
    vector<int> temp3(temp1.size() + temp2.size()), ans;
    merge(temp1.begin(), temp1.end(), temp2.begin(), temp2.end(), temp3.begin());
    int pp = temp3.size();
    for (int i=0;i<pp;i++){
        if (i == 0) ans.pb(temp3[i]);
        else{
            if (temp3[i] == ans.back()) continue;
            ans.pb(temp3[i]);
        }
    }
    while (ans.size() > a) ans.pop_back();
    cout << ans.size() << " ";
    for (auto x : ans) cout << x << " "; cout << el;
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m >> q;
    for (int i=1;i<n;i++){
        int a, b;
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    for (int i=1;i<=m;i++){
        int a;
        cin >> a;
        if (city[a].size() < 10) city[a].pb(i);
    }
    init();

    while (q--){
        int v, u, a;
        cin >> v >> u >> a;

        solve(v, u, a);
    }

    return 0;
}


#include <bits/stdc++.h>

#define fi first
#define se second
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define el '\n'

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int N = 1e5 + 10;
const int INF = 1e9;

int n, m, q;
vector<int> adj[N];
vector<int> city[N]; // ids of population

int parent[N], dep[N];
int heavy[N], head[N], pos[N], cur_pos;
vector<int> path;
int pathlen;

vector<int> t[8 * N];

void build(int v, int tl, int tr){
    if (tl == tr){
        for (auto x : city[path[tl]]){
            t[v].pb(x);
        }
        return;
    }
    int tm = (tl + tr) / 2;
    build(v * 2, tl, tm);
    build(v * 2 + 1, tm + 1, tr);
    t[v].resize(t[v * 2].size() + t[v * 2 + 1].size());
    merge(t[v * 2].begin(), t[v * 2].end(), t[v * 2 + 1].begin(), t[v * 2 + 1].end(), t[v].begin());
    while (t[v].size() > 10) t[v].pop_back();
}
vector<int> ask(int v, int tl, int tr, int l, int r){
    vector<int> ret;
    if (l > r) return ret;
    else if (l <= tl && tr <= r){
        return t[v];
    }
    int tm = (tl + tr) / 2;
    vector<int> temp1, temp2;
    temp1 = ask(v * 2, tl, tm, l, min(tm, r));
    temp2 = ask(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r);
    ret.resize(temp1.size() + temp2.size());
    merge(temp1.begin(), temp1.end(), temp2.begin(), temp2.end(), ret.begin());
    while (ret.size() > 10) ret.pop_back();
    return ret;
}
vector<int> query(int a, int b){
    vector<int> ret, nret, temp;
    for (; head[a] != head[b]; b = parent[head[b]]){
        if (dep[a] > dep[b]) swap(a, b);
        temp = ask(1, 0, pathlen - 1, pos[head[b]], pos[b]);
        nret.resize(ret.size() + temp.size());
        merge(ret.begin(), ret.end(), temp.begin(), temp.end(), nret.begin());
        while (nret.size() > 10) nret.pop_back();
        ret = nret;
    }
    if (dep[a] > dep[b]) swap(a, b);
    temp = ask(1, 0, pathlen - 1, pos[a], pos[b]);
    nret.resize(ret.size() + temp.size());
    merge(ret.begin(), ret.end(), temp.begin(), temp.end(), nret.begin());
    while (nret.size() > 10) nret.pop_back();
    ret = nret;
    return ret;
}
int dfs_init(int node, int p){
    if (node != 1) dep[node] = dep[p] + 1;
    parent[node] = p;

    int ret = 1, mx = 0;
    for (auto x : adj[node]){
        if (x == p) continue;
        int cur = dfs_init(x, node);
        ret += cur;
        if (mx < cur){
            heavy[node] = x;
            mx = cur;
        }
    }
    return ret;
}

void decompose(int node, int h){
    head[node] = h;
    pos[node] = cur_pos++;
    path.pb(node);
    if (heavy[node]){
        decompose(heavy[node], h);
    }
    for (auto x : adj[node]){
        if (x == parent[node] || x == heavy[node]) continue;
        decompose(x, x);
    }
}

void init(){
    int dummy = dfs_init(1, 1);
    decompose(1, 1);
    dep[0] = INF;
    pathlen = path.size();

    build(1, 0, pathlen - 1);
}

void solve(int v, int u, int a){
    vector<int> temp, ans;
    temp = query(v, u);
    int pp = temp.size();
    for (int i=0;i<pp;i++){
        if (i == 0) ans.pb(temp[i]);
        else{
            if (temp[i] == ans.back()) continue;
            ans.pb(temp[i]);
        }
    }
    while (ans.size() > a) ans.pop_back();
    cout << ans.size() << " ";
    for (auto x : ans) cout << x << " "; cout << el;
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m >> q;
    for (int i=1;i<n;i++){
        int a, b;
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    for (int i=1;i<=m;i++){
        int a;
        cin >> a;
        if (city[a].size() < 10) city[a].pb(i);
    }
    init();

    while (q--){
        int v, u, a;
        cin >> v >> u >> a;

        solve(v, u, a);
    }

    return 0;
}


#include <bits/stdc++.h>

#define fi first
#define se second
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define el '\n'

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int N = 1e5 + 10, M = 18, MX = 150;

int n, m, q;
vector<int> adj[N];

int tin[N], tout[N], timer;
int up[N][M];
vector<int> city[N], t[8 * N]; //[M];

int ar[2 * N];

vector<int> gabung(const vector<int>& va, const vector<int>& vb){
    vector<int> temp(va.size() + vb.size());
    merge(va.begin(), va.end(), vb.begin(), vb.end(), temp.begin());
    vector<int> ret;
    int len = temp.size();
    for (int i=0;i<len;i++){
        if (i == 0){
            ret.pb(temp[i]);
        } else{
            if (!ret.empty() && temp[i] == ret.back()) ret.pop_back();
            else if (temp[i] != temp[i - 1]) ret.pb(temp[i]);
        }
    }
    while ((int)ret.size() > MX) ret.pop_back();
    return ret;
}

void build(int v, int tl, int tr){
    if (tl == tr){
        t[v] = city[ar[tl]];
        return;
    }
    int tm = (tl + tr) / 2;
    build(v * 2, tl, tm);
    build(v * 2 + 1, tm + 1, tr);
    t[v] = gabung(t[v * 2], t[v * 2 + 1]);
}

vector<int> ask(int v, int tl, int tr, int l, int r){
    vector<int> ret;
    if (l > r) return ret;
    else if (l <= tl && tr <= r){
        return t[v];
    }
    int tm = (tl + tr) / 2;
    return gabung(ask(v * 2, tl, tm, l, min(tm, r)), ask(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r));
}

void dfs_init(int node, int p){
    tin[node] = ++timer;
    ar[timer] = node;
    up[node][0] = p;
    for (int i=1;i<M;i++){
        int mid = up[node][i - 1];
        up[node][i] = up[mid][i - 1];
    }

    for (auto x : adj[node]){
        if (x == p) continue;
        dfs_init(x, node);
    }
    tout[node] = ++timer;
    ar[timer] = node;
}

bool is_ancestor(int a, int b){
    return tin[a] <= tin[b] && tout[b] <= tout[a];
}

int LCA(int a, int b){
    if (!is_ancestor(a, b) && !is_ancestor(b, a)){
        for (int i=M - 1;i>=0;i--){
            int na = up[a][i];
            if (!is_ancestor(na, b)){
                a = na;
            }
        }
        a = up[a][0];
    }
    if (is_ancestor(b, a)) swap(a, b);
    assert(is_ancestor(a, b));
    return a;
}

void solve(int a, int b, int k){
    int lca = LCA(a, b);
    vector<int> temp1, temp2;
    temp1 = ask(1, 1, timer, tin[lca], tin[a]);
    temp2 = ask(1, 1, timer, tin[lca], tin[b]);
    set<int> setdah;
    for (auto x : temp1) setdah.insert(x);
    for (auto x : temp2) setdah.insert(x);
    k = min(k, (int)setdah.size());
    cout << k << " ";
    for (auto x : setdah){
        if (k-- > 0){
            cout << x << " ";
        }
    }
    cout << el;
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m >> q;
    for (int i=1;i<n;i++){
        int a, b;
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    for (int i=1;i<=m;i++){
        int a;
        cin >> a;
        if ((int)city[a].size() < 10) city[a].pb(i);
    }
    dfs_init(1, 1);
    build(1, 1, timer);
    while (q--){
        int v, u, a;
        cin >> v >> u >> a;
        solve(v, u, a);
    }

    return 0;
}


#include <bits/stdc++.h>

#define fi first
#define se second
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define el '\n'

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int N = 1e5 + 10;
const int INF = 1e9;

int n, m, q;
vector<int> adj[N];
vector<int> city[N]; // ids of population

int parent[N], dep[N];
int heavy[N], head[N], pos[N], cur_pos;
int tin[N], timer;
vector<int> path, epath;
int pathlen, epathlen;

int tlca[8 * N];
vector<int> t[8 * N];

void buildlca(int v, int tl, int tr){
    if (tl == tr){
        tlca[v] = epath[tl];
        return;
    }
    int tm = (tl + tr) / 2;
    buildlca(v * 2, tl, tm);
    buildlca(v * 2 + 1, tm + 1, tr);
    if (dep[tlca[v * 2]] < dep[tlca[v * 2 + 1]])
        tlca[v] = tlca[v * 2];
    else
        tlca[v] = tlca[v * 2 + 1];
}
int asklca(int v, int tl, int tr, int l, int r){
    if (l > r) return 0;
    else if (l <= tl && tr <= r){
        return tlca[v];
    }
    int tm = (tl + tr) / 2;
    int temp1 = asklca(v * 2, tl, tm, l, min(tm, r));
    int temp2 = asklca(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r);
    if (dep[temp1] < dep[temp2]) return temp1;
    return temp2;
}

int LCA(int a, int b){
    if (tin[a] > tin[b]) swap(a, b);
    return asklca(1, 0, epathlen - 1, tin[a], tin[b]);
}

void build(int v, int tl, int tr){
    if (tl == tr){
        for (auto x : city[path[tl]]){
            t[v].pb(x);
        }
        return;
    }
    int tm = (tl + tr) / 2;
    build(v * 2, tl, tm);
    build(v * 2 + 1, tm + 1, tr);
    t[v].resize(t[v * 2].size() + t[v * 2 + 1].size());
    merge(t[v * 2].begin(), t[v * 2].end(), t[v * 2 + 1].begin(), t[v * 2 + 1].end(), t[v].begin());
    while (t[v].size() > 10) t[v].pop_back();
}
vector<int> ask(int v, int tl, int tr, int l, int r){
    vector<int> ret;
    if (l > r) return ret;
    else if (l <= tl && tr <= r){
        return t[v];
    }
    int tm = (tl + tr) / 2;
    vector<int> temp1, temp2;
    temp1 = ask(v * 2, tl, tm, l, min(tm, r));
    temp2 = ask(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r);
    ret.resize(temp1.size() + temp2.size());
    merge(temp1.begin(), temp1.end(), temp2.begin(), temp2.end(), ret.begin());
    while (ret.size() > 10) ret.pop_back();
    return ret;
}
vector<int> query(int a, int b){
    vector<int> ret, nret, temp;
    for (; head[a] != head[b]; b = parent[head[b]]){
        if (dep[a] > dep[b]) swap(a, b);
        temp = ask(1, 0, pathlen - 1, pos[head[b]], pos[b]);
        nret.resize(ret.size() + temp.size());
        merge(ret.begin(), ret.end(), temp.begin(), temp.end(), nret.begin());
        while (nret.size() > 10) nret.pop_back();
        ret = nret;
    }
    if (dep[a] > dep[b]) swap(a, b);
    temp = ask(1, 0, pathlen - 1, pos[a], pos[b]);
    nret.resize(ret.size() + temp.size());
    merge(ret.begin(), ret.end(), temp.begin(), temp.end(), nret.begin());
    while (nret.size() > 10) nret.pop_back();
    ret = nret;
    return ret;
}

void dfs_euler(int node){
    epath.pb(node);
    tin[node] = timer++;
    for (auto x : adj[node]){
        if (x == parent[node]) continue;
        dfs_euler(x);
        epath.pb(node);
        timer++;
    }
}

int dfs_init(int node, int p){
    if (node != 1) dep[node] = dep[p] + 1;
    parent[node] = p;

    int ret = 0, mx = 0;
    for (auto x : adj[node]){
        if (x == p) continue;
        int cur = dfs_init(x, node);
        ret += cur;
        if (mx < cur){
            heavy[node] = x;
            mx = cur;
        }
    }
    return ret;
}

void decompose(int node, int h){
    head[node] = h;
    pos[node] = cur_pos++;
    path.pb(node);
    if (heavy[node] != 0){
        decompose(heavy[node], h);
    }
    for (auto x : adj[node]){
        if (x == parent[node] || x == h) continue;
        decompose(x, x);
    }
}

void init(){
    dfs_init(1, 1);
    dfs_euler(1);
    decompose(1, 1);
    dep[0] = INF;
    pathlen = path.size();
    epathlen = epath.size();

    buildlca(1, 0, epathlen - 1);
    build(1, 0, pathlen - 1);

    // for (auto x : epath){
    //     cout << x << "::" << dep[x] << ", ";
    // }
    // cout << el;
}

void solve(int v, int u, int a){
    int lca = LCA(v, u);
    vector<int> temp1, temp2;
    temp1 = query(lca, v);
    temp2 = query(lca, u);
    vector<int> temp3(temp1.size() + temp2.size()), ans;
    merge(temp1.begin(), temp1.end(), temp2.begin(), temp2.end(), temp3.begin());
    int pp = temp3.size();
    for (int i=0;i<pp;i++){
        if (i == 0) ans.pb(temp3[i]);
        else{
            if (temp3[i] == ans.back()) continue;
            ans.pb(temp3[i]);
        }
    }
    while (ans.size() > a) ans.pop_back();
    cout << ans.size() << " ";
    for (auto x : ans) cout << x << " "; cout << el;
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m >> q;
    for (int i=1;i<n;i++){
        int a, b;
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    for (int i=1;i<=m;i++){
        int a;
        cin >> a;
        if (city[a].size() < 10) city[a].pb(i);
    }
    init();

    while (q--){
        int v, u, a;
        cin >> v >> u >> a;

        solve(v, u, a);
    }

    return 0;
}


#include <bits/stdc++.h>

#define fi first
#define se second
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define el '\n'

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int N = 1e5 + 10;
const int INF = 1e9;

int n, m, q;
vector<int> adj[N];
vector<int> city[N]; // ids of population

int parent[N], dep[N];
int heavy[N], head[N], pos[N], cur_pos;
vector<int> path;
int pathlen;

vector<int> t[8 * N];

void build(int v, int tl, int tr){
    if (tl == tr){
        for (auto x : city[path[tl]]){
            t[v].pb(x);
        }
        return;
    }
    int tm = (tl + tr) / 2;
    build(v * 2, tl, tm);
    build(v * 2 + 1, tm + 1, tr);
    t[v].resize(t[v * 2].size() + t[v * 2 + 1].size());
    merge(t[v * 2].begin(), t[v * 2].end(), t[v * 2 + 1].begin(), t[v * 2 + 1].end(), t[v].begin());
    while (t[v].size() > 10) t[v].pop_back();
}
vector<int> ask(int v, int tl, int tr, int l, int r){
    vector<int> ret;
    if (l > r) return ret;
    else if (l <= tl && tr <= r){
        return t[v];
    }
    int tm = (tl + tr) / 2;
    vector<int> temp1, temp2;
    temp1 = ask(v * 2, tl, tm, l, min(tm, r));
    temp2 = ask(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r);
    ret.resize(temp1.size() + temp2.size());
    merge(temp1.begin(), temp1.end(), temp2.begin(), temp2.end(), ret.begin());
    while (ret.size() > 10) ret.pop_back();
    return ret;
}
vector<int> query(int a, int b){
    vector<int> ret, nret, temp;
    for (; head[a] != head[b]; b = parent[head[b]]){
        if (dep[head[a]] > dep[head[b]]) swap(a, b);
        temp = ask(1, 0, pathlen - 1, pos[head[b]], pos[b]);
        nret.resize(ret.size() + temp.size());
        merge(ret.begin(), ret.end(), temp.begin(), temp.end(), nret.begin());
        while (nret.size() > 10) nret.pop_back();
        ret = nret;
    }
    if (dep[a] > dep[b]) swap(a, b);
    temp = ask(1, 0, pathlen - 1, pos[a], pos[b]);
    nret.resize(ret.size() + temp.size());
    merge(ret.begin(), ret.end(), temp.begin(), temp.end(), nret.begin());
    ret.clear();
    for (auto x : nret){
        if (ret.empty()){
            ret.pb(x);
        } else{
            if (x == ret.back()) continue;
            ret.pb(x);
        }
    }
    while (ret.size() > 10) ret.pop_back();
    return ret;
}
int dfs_init(int node, int p){
    if (node != 1) dep[node] = dep[p] + 1;
    parent[node] = p;

    int ret = 1, mx = 0;
    for (auto x : adj[node]){
        if (x == p) continue;
        int cur = dfs_init(x, node);
        ret += cur;
        if (mx < cur){
            heavy[node] = x;
            mx = cur;
        }
    }
    return ret;
}

void decompose(int node, int h){
    head[node] = h;
    pos[node] = cur_pos++;
    path.pb(node);
    if (heavy[node]){
        decompose(heavy[node], h);
    }
    for (auto x : adj[node]){
        if (x == parent[node] || x == heavy[node]) continue;
        decompose(x, x);
    }
}

void init(){
    int dummy = dfs_init(1, 1);
    decompose(1, 1);
    dep[0] = INF;
    pathlen = path.size();

    build(1, 0, pathlen - 1);
}

void solve(int v, int u, int a){
    vector<int> temp, ans;
    temp = query(v, u);
    int pp = temp.size();
    for (int i=0;i<pp;i++){
        if (i == 0) ans.pb(temp[i]);
        else{
            if (temp[i] == ans.back()) continue;
            ans.pb(temp[i]);
        }
    }
    while (ans.size() > a) ans.pop_back();
    cout << ans.size() << " ";
    for (auto x : ans) cout << x << " "; cout << el;
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m >> q;
    for (int i=1;i<n;i++){
        int a, b;
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    for (int i=1;i<=m;i++){
        int a;
        cin >> a;
        if (city[a].size() < 10) city[a].pb(i);
    }
    init();

    while (q--){
        int v, u, a;
        cin >> v >> u >> a;

        solve(v, u, a);
    }

    return 0;
}


#include <bits/stdc++.h>

#define fi first
#define se second
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define el '\n'

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int N = 1e5 + 10, M = 18;

int n, m, q;
vector<int> adj[N];

int tin[N], tout[N], timer;
int up[N][M];
vector<int> city[N], t[8 * N]; //[M];

int ar[2 * N];

vector<int> gabung(const vector<int>& va, const vector<int>& vb){
    vector<int> temp(va.size() + vb.size());
    merge(va.begin(), va.end(), vb.begin(), vb.end(), temp.begin());
    vector<int> ret;
    int len = temp.size();
    for (int i=0;i<len;i++){
        if (i == 0){
            ret.pb(temp[i]);
        } else{
            if (temp[i] != temp[i - 1]){
                ret.pb(temp[i]);
            } else ret.pop_back();
        }
    }
    while ((int)ret.size() > 10) ret.pop_back();
    return ret;
}

void build(int v, int tl, int tr){
    if (tl == tr){
        t[v] = city[ar[tl]];
        return;
    }
    int tm = (tl + tr) / 2;
    build(v * 2, tl, tm);
    build(v * 2 + 1, tm + 1, tr);
    t[v] = gabung(t[v * 2], t[v * 2 + 1]);
}

vector<int> ask(int v, int tl, int tr, int l, int r){
    vector<int> ret;
    if (l > r) return ret;
    else if (l <= tl && tr <= r){
        return t[v];
    }
    int tm = (tl + tr) / 2;
    return gabung(ask(v * 2, tl, tm, l, min(tm, r)), ask(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r));
}

void dfs_init(int node, int p){
    tin[node] = ++timer;
    ar[timer] = node;
    up[node][0] = p;
    for (int i=1;i<M;i++){
        int mid = up[node][i - 1];
        up[node][i] = up[mid][i - 1];
    }

    for (auto x : adj[node]){
        if (x == p) continue;
        dfs_init(x, node);
    }
    tout[node] = ++timer;
    ar[timer] = node;
}

bool is_ancestor(int a, int b){
    return tin[a] <= tin[b] && tout[b] <= tout[a];
}

int LCA(int a, int b){
    set<int> ans;
    if (!is_ancestor(a, b) && !is_ancestor(b, a)){
        for (int i=M - 1;i>=0;i--){
            int na = up[a][i];
            if (!is_ancestor(na, b)){
                a = na;
            }
        }
        a = up[a][0];
    }
    if (is_ancestor(b, a)) swap(a, b);
    assert(is_ancestor(a, b));
    return a;
}

void solve(int a, int b, int k){
    int lca = LCA(a, b);
    vector<int> temp1, temp2;
    temp1 = ask(1, 1, timer, tin[lca], tin[a]);
    temp2 = ask(1, 1, timer, tin[lca], tin[b]);
    set<int> setdah;
    for (auto x : temp1) setdah.insert(x);
    for (auto x : temp2) setdah.insert(x);
    k = min(k, (int)setdah.size());
    cout << k << " ";
    for (auto x : setdah){
        if (k-- > 0){
            cout << x << " ";
        }
    }
    cout << el;
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m >> q;
    for (int i=1;i<n;i++){
        int a, b;
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    for (int i=1;i<=m;i++){
        int a;
        cin >> a;
        if ((int)city[a].size() < 10) city[a].pb(i);
    }
    dfs_init(1, 1);
    build(1, 1, timer);
    while (q--){
        int v, u, a;
        cin >> v >> u >> a;
        solve(v, u, a);
    }

    return 0;
}


#include <bits/stdc++.h>

#define fi first
#define se second
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define el '\n'

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int N = 1e5 + 10;
const int INF = 1e9;

int n, m, q;
vector<int> adj[N];
vector<int> city[N]; // ids of population

int parent[N], dep[N];
int heavy[N], head[N], pos[N], cur_pos;
int tin[N], timer;
vector<int> path, epath;
int pathlen, epathlen;

int tlca[8 * N];
vector<int> t[8 * N];

void buildlca(int v, int tl, int tr){
    if (tl == tr){
        tlca[v] = epath[tl];
        return;
    }
    int tm = (tl + tr) / 2;
    buildlca(v * 2, tl, tm);
    buildlca(v * 2 + 1, tm + 1, tr);
    if (dep[tlca[v * 2]] < dep[tlca[v * 2 + 1]])
        tlca[v] = tlca[v * 2];
    else
        tlca[v] = tlca[v * 2 + 1];
}
int asklca(int v, int tl, int tr, int l, int r){
    if (l > r) return 0;
    else if (l <= tl && tr <= r){
        return tlca[v];
    }
    int tm = (tl + tr) / 2;
    int temp1 = asklca(v * 2, tl, tm, l, min(tm, r));
    int temp2 = asklca(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r);
    if (dep[temp1] < dep[temp2]) return temp1;
    return temp2;
}

int LCA(int a, int b){
    if (tin[a] > tin[b]) swap(a, b);
    return asklca(1, 0, epathlen - 1, tin[a], tin[b]);
}

void build(int v, int tl, int tr){
    if (tl == tr){
        for (auto x : city[path[tl]]){
            t[v].pb(x);
        }
        return;
    }
    int tm = (tl + tr) / 2;
    build(v * 2, tl, tm);
    build(v * 2 + 1, tm + 1, tr);
    t[v].resize(t[v * 2].size() + t[v * 2 + 1].size());
    merge(t[v * 2].begin(), t[v * 2].end(), t[v * 2 + 1].begin(), t[v * 2 + 1].end(), t[v].begin());
    while (t[v].size() > 10) t[v].pop_back();
}
vector<int> ask(int v, int tl, int tr, int l, int r){
    vector<int> ret;
    if (l > r) return ret;
    else if (l <= tl && tr <= r){
        return t[v];
    }
    int tm = (tl + tr) / 2;
    vector<int> temp1, temp2;
    temp1 = ask(v * 2, tl, tm, l, min(tm, r));
    temp2 = ask(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r);
    ret.resize(temp1.size() + temp2.size());
    merge(temp1.begin(), temp1.end(), temp2.begin(), temp2.end(), ret.begin());
    while (ret.size() > 10) ret.pop_back();
    return ret;
}
vector<int> query(int a, int b){
    vector<int> ret, nret, temp;
    for (; head[a] != head[b]; b = parent[head[b]]){
        if (dep[a] > dep[b]) swap(a, b);
        temp = ask(1, 0, pathlen - 1, pos[head[b]], pos[b]);
        nret.resize(ret.size() + temp.size());
        merge(ret.begin(), ret.end(), temp.begin(), temp.end(), nret.begin());
        while (nret.size() > 10) nret.pop_back();
        ret = nret;
    }
    if (dep[a] > dep[b]) swap(a, b);
    temp = ask(1, 0, pathlen - 1, pos[a], pos[b]);
    nret.resize(ret.size() + temp.size());
    merge(ret.begin(), ret.end(), temp.begin(), temp.end(), nret.begin());
    while (nret.size() > 10) nret.pop_back();
    ret = nret;
    return ret;
}

void dfs_euler(int node){
    epath.pb(node);
    tin[node] = timer++;
    for (auto x : adj[node]){
        if (x == parent[node]) continue;
        dfs_euler(x);
        epath.pb(node);
        timer++;
    }
}

int dfs_init(int node, int p){
    if (node != 1) dep[node] = dep[p] + 1;
    parent[node] = p;

    int ret = 1, mx = 0;
    for (auto x : adj[node]){
        if (x == p) continue;
        int cur = dfs_init(x, node);
        ret += cur;
        if (mx < cur){
            heavy[node] = x;
            mx = cur;
        }
    }
    return ret;
}

void decompose(int node, int h){
    head[node] = h;
    pos[node] = cur_pos++;
    path.pb(node);
    if (heavy[node] != 0){
        decompose(heavy[node], h);
    }
    for (auto x : adj[node]){
        if (x == parent[node] || x == h) continue;
        decompose(x, x);
    }
}

void init(){
    dfs_init(1, 1);
    dfs_euler(1);
    decompose(1, 1);
    dep[0] = INF;
    pathlen = path.size();
    epathlen = epath.size();

    buildlca(1, 0, epathlen - 1);
    build(1, 0, pathlen - 1);
}

void solve(int v, int u, int a){
    int lca = LCA(v, u);
    vector<int> temp1, temp2;
    temp1 = query(lca, v);
    temp2 = query(lca, u);
    vector<int> temp3(temp1.size() + temp2.size()), ans;
    merge(temp1.begin(), temp1.end(), temp2.begin(), temp2.end(), temp3.begin());
    int pp = temp3.size();
    for (int i=0;i<pp;i++){
        if (i == 0) ans.pb(temp3[i]);
        else{
            if (temp3[i] == ans.back()) continue;
            ans.pb(temp3[i]);
        }
    }
    while (ans.size() > a) ans.pop_back();
    cout << ans.size() << " ";
    for (auto x : ans) cout << x << " "; cout << el;
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m >> q;
    for (int i=1;i<n;i++){
        int a, b;
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    for (int i=1;i<=m;i++){
        int a;
        cin >> a;
        if (city[a].size() < 10) city[a].pb(i);
    }
    init();

    while (q--){
        int v, u, a;
        cin >> v >> u >> a;

        solve(v, u, a);
    }

    return 0;
}


#include <bits/stdc++.h>

#define fi first
#define se second
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define el '\n'

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int N = 1e5 + 10;
const int INF = 1e9;

int n, m, q;
vector<int> adj[N];
vector<int> city[N]; // ids of population

int parent[N], dep[N];
int heavy[N], head[N], pos[N], cur_pos;
vector<int> path;
int pathlen;

vector<int> t[8 * N];

void build(int v, int tl, int tr){
    if (tl == tr){
        for (auto x : city[path[tl]]){
            t[v].pb(x);
        }
        return;
    }
    int tm = (tl + tr) / 2;
    build(v * 2, tl, tm);
    build(v * 2 + 1, tm + 1, tr);
    t[v].resize(t[v * 2].size() + t[v * 2 + 1].size());
    merge(t[v * 2].begin(), t[v * 2].end(), t[v * 2 + 1].begin(), t[v * 2 + 1].end(), t[v].begin());
    while (t[v].size() > 10) t[v].pop_back();
}
vector<int> ask(int v, int tl, int tr, int l, int r){
    vector<int> ret;
    if (l > r) return ret;
    else if (l <= tl && tr <= r){
        return t[v];
    }
    int tm = (tl + tr) / 2;
    vector<int> temp1, temp2;
    temp1 = ask(v * 2, tl, tm, l, min(tm, r));
    temp2 = ask(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r);
    ret.resize(temp1.size() + temp2.size());
    merge(temp1.begin(), temp1.end(), temp2.begin(), temp2.end(), ret.begin());
    while (ret.size() > 10) ret.pop_back();
    return ret;
}
vector<int> query(int a, int b){
    vector<int> ret, nret, temp;
    for (; head[a] != head[b]; b = parent[head[b]]){
        if (dep[a] > dep[b]) swap(a, b);
        temp = ask(1, 0, pathlen - 1, pos[head[b]], pos[b]);
        nret.resize(ret.size() + temp.size());
        merge(ret.begin(), ret.end(), temp.begin(), temp.end(), nret.begin());
        while (nret.size() > 10) nret.pop_back();
        ret = nret;
    }
    if (dep[a] > dep[b]) swap(a, b);
    temp = ask(1, 0, pathlen - 1, pos[a], pos[b]);
    nret.resize(ret.size() + temp.size());
    merge(ret.begin(), ret.end(), temp.begin(), temp.end(), nret.begin());
    ret.clear();
    for (auto x : nret){
        if (ret.empty()){
            ret.pb(x);
        } else{
            if (x == ret.back()) continue;
            ret.pb(x);
        }
    }
    while (ret.size() > 10) ret.pop_back();
    return ret;
}
int dfs_init(int node, int p){
    if (node != 1) dep[node] = dep[p] + 1;
    parent[node] = p;

    int ret = 1, mx = 0;
    for (auto x : adj[node]){
        if (x == p) continue;
        int cur = dfs_init(x, node);
        ret += cur;
        if (mx < cur){
            heavy[node] = x;
            mx = cur;
        }
    }
    return ret;
}

void decompose(int node, int h){
    head[node] = h;
    pos[node] = cur_pos++;
    path.pb(node);
    if (heavy[node]){
        decompose(heavy[node], h);
    }
    for (auto x : adj[node]){
        if (x == parent[node] || x == heavy[node]) continue;
        decompose(x, x);
    }
}

void init(){
    int dummy = dfs_init(1, 1);
    decompose(1, 1);
    dep[0] = INF;
    pathlen = path.size();

    build(1, 0, pathlen - 1);
}

void solve(int v, int u, int a){
    vector<int> temp, ans;
    temp = query(v, u);
    int pp = temp.size();
    for (int i=0;i<pp;i++){
        if (i == 0) ans.pb(temp[i]);
        else{
            if (temp[i] == ans.back()) continue;
            ans.pb(temp[i]);
        }
    }
    while (ans.size() > a) ans.pop_back();
    cout << ans.size() << " ";
    for (auto x : ans) cout << x << " "; cout << el;
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m >> q;
    for (int i=1;i<n;i++){
        int a, b;
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    for (int i=1;i<=m;i++){
        int a;
        cin >> a;
        if (city[a].size() < 10) city[a].pb(i);
    }
    init();

    while (q--){
        int v, u, a;
        cin >> v >> u >> a;

        solve(v, u, a);
    }

    return 0;
}


#include <bits/stdc++.h>

#define fi first
#define se second
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define el '\n'

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int N = 1e5 + 10, M = 18;

int n, m, q;
vector<int> adj[N];

int tin[N], tout[N], timer;
int up[N][M];
set<int> city[N][M];

void dfs_init(int node, int p){
    tin[node] = ++timer;
    up[node][0] = p;
    for (int i=1;i<M;i++){
        int mid = up[node][i - 1];
        up[node][i] = up[mid][i - 1];
        for (auto x : city[node][i - 1]){
            city[node][i].insert(x);
        }
        for (auto x : city[mid][i - 1]){
            city[node][i].insert(x);
        }
        while (city[node][i].size() > 10) city[node][i].erase(*city[node][i].rbegin());
    }

    for (auto x : adj[node]){
        if (x == p) continue;
        dfs_init(x, node);
    }

    tout[node] = ++timer;
}

bool is_ancestor(int a, int b){
    return tin[a] <= tin[b] && tout[b] <= tout[a];
}

void solve(int a, int b, int k){
    set<int> ans;
    if (!is_ancestor(a, b) && !is_ancestor(b, a)){
        for (int i=M - 1;i>=0;i--){
            int na = up[a][i];
            if (!is_ancestor(na, b)){
                for (auto x : city[a][i]){
                    ans.insert(x);
                }
                a = na;
            }
        }
        for (auto x : city[a][0]){
            ans.insert(x);
        }
        a = up[a][0];
    }
    if (is_ancestor(b, a)) swap(a, b);
    assert(is_ancestor(a, b));
    for (int i=M - 1;i>=0;i--){
        int nb = up[b][i];
        if (!is_ancestor(nb, a)){
            for (auto x : city[b][i]){
                ans.insert(x);
            }
            b = nb;
        }
    }
    for (auto x : city[b][0]){
        ans.insert(x);
    }
    b = up[b][0];
    for (auto x : city[a][0]){
        ans.insert(x);
    }
    while ((int)ans.size() > k) ans.erase(*ans.rbegin());
    cout << (int)ans.size() << " ";
    for (auto x : ans){
        cout << x << " ";
    }
    cout << el;
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m >> q;
    for (int i=1;i<n;i++){
        int a, b;
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    for (int i=1;i<=m;i++){
        int a;
        cin >> a;
        if ((int)city[a][0].size() < 10) city[a][0].insert(i);
    }
    // for (int i=1;i<=n;i++){
    //     for (auto x : city[i][0]) cout << x << " ";
    //     cout << el;
    // }
    dfs_init(1, 1);
    while (q--){
        int v, u, a;
        cin >> v >> u >> a;
        solve(v, u, a);
    }

    return 0;
}


#include <bits/stdc++.h>

#define fi first
#define se second
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define el '\n'

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int N = 1e5 + 10, M = 18;

int n, m, q;
vector<int> adj[N];

int tin[N], tout[N], timer;
int up[N][M];
vector<int> city[N], t[8 * N]; //[M];

int ar[2 * N];

vector<int> gabung(const vector<int>& va, const vector<int>& vb){
    vector<int> temp(va.size() + vb.size());
    merge(va.begin(), va.end(), vb.begin(), vb.end(), temp.begin());
    vector<int> ret;
    int len = temp.size();
    for (int i=0;i<len;i++){
        if (i == 0){
            ret.pb(temp[i]);
        } else{
            if (temp[i] == ret.back()) ret.pop_back();
            else if (temp[i] != temp[i - 1]) ret.pb(temp[i]);
        }
    }
    while ((int)ret.size() > 10) ret.pop_back();
    return ret;
}

void build(int v, int tl, int tr){
    if (tl == tr){
        t[v] = city[ar[tl]];
        return;
    }
    int tm = (tl + tr) / 2;
    build(v * 2, tl, tm);
    build(v * 2 + 1, tm + 1, tr);
    t[v] = gabung(t[v * 2], t[v * 2 + 1]);
}

vector<int> ask(int v, int tl, int tr, int l, int r){
    vector<int> ret;
    if (l > r) return ret;
    else if (l <= tl && tr <= r){
        return t[v];
    }
    int tm = (tl + tr) / 2;
    return gabung(ask(v * 2, tl, tm, l, min(tm, r)), ask(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r));
}

void dfs_init(int node, int p){
    tin[node] = ++timer;
    ar[timer] = node;
    up[node][0] = p;
    for (int i=1;i<M;i++){
        int mid = up[node][i - 1];
        up[node][i] = up[mid][i - 1];
    }

    for (auto x : adj[node]){
        if (x == p) continue;
        dfs_init(x, node);
    }
    tout[node] = ++timer;
    ar[timer] = node;
}

bool is_ancestor(int a, int b){
    return tin[a] <= tin[b] && tout[b] <= tout[a];
}

int LCA(int a, int b){
    set<int> ans;
    if (!is_ancestor(a, b) && !is_ancestor(b, a)){
        for (int i=M - 1;i>=0;i--){
            int na = up[a][i];
            if (!is_ancestor(na, b)){
                a = na;
            }
        }
        a = up[a][0];
    }
    if (is_ancestor(b, a)) swap(a, b);
    assert(is_ancestor(a, b));
    return a;
}

void solve(int a, int b, int k){
    int lca = LCA(a, b);
    vector<int> temp1, temp2;
    temp1 = ask(1, 1, timer, tin[lca], tin[a]);
    temp2 = ask(1, 1, timer, tin[lca], tin[b]);
    set<int> setdah;
    for (auto x : temp1) setdah.insert(x);
    for (auto x : temp2) setdah.insert(x);
    k = min(k, (int)setdah.size());
    cout << k << " ";
    for (auto x : setdah){
        if (k-- > 0){
            cout << x << " ";
        }
    }
    cout << el;
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m >> q;
    for (int i=1;i<n;i++){
        int a, b;
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    for (int i=1;i<=m;i++){
        int a;
        cin >> a;
        if ((int)city[a].size() < 10) city[a].pb(i);
    }
    dfs_init(1, 1);
    build(1, 1, timer);
    while (q--){
        int v, u, a;
        cin >> v >> u >> a;
        solve(v, u, a);
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int Max = 1e5+3, Log = 17+1;
vector<int> adj[Max];
int memo[Max][Log];
vector<int> st[Max][Log];
int depth[Max];
vector<int> value[Max];

void dfs(int node, int prev, int Depth = 0) {
    depth[node] = Depth;
    memo[node][0] = prev;
    vector<int> &temp = st[node][0];
    for(int val : value[node]) {
        temp.push_back(val);
    }
    sort(temp.begin(), temp.end());
    if(temp.size() > 10) temp.resize(10);
    for(int i = 1; i < Log; ++i) {
        memo[node][i] = memo[memo[node][i-1]][i-1];
        vector<int> &temp2 = st[node][i];
        for(int &val : st[node][i-1]) {
            temp2.push_back(val);
        }
        for(int &val : st[memo[node][i-1]][i-1]) {
            temp2.push_back(val);
        }
        sort(temp2.begin(), temp2.end());
        if((int)temp2.size() > 10) {
            temp2.resize(10);
        }
    }
    for(int to : adj[node]) {
        if(to == prev) continue;
        dfs(to, node, Depth+1);
    }
}

vector<int> LCA(int x, int y, int a) {
    if(depth[x] < depth[y]) swap(x,y);
    int diff = depth[x] - depth[y];
    vector<int> res;
    for(int k = Log-1; k >= 0; --k) {
        if(diff&(1<<k)) {
            for(int &val : st[x][k]) {
                res.push_back(val);
            }
            x = memo[x][k];
        }
    }
    for(int k = Log-1; k >= 0; --k) {
        if(memo[x][k] != memo[y][k]) {
            for(int &val : st[x][k]) {
                res.push_back(val);
            }
            for(int &val : st[y][k]) {
                res.push_back(val);
            }
            x = memo[x][k];
            y = memo[y][k];
        }
    }
    if(x != y) {
        for(int &val : st[x][0]) {
            res.push_back(val);
        }
        for(int &val : st[y][0]) {
            res.push_back(val);
        }
        x = memo[x][0];
    }
    for(int &val : value[x]) {
        res.push_back(val);
    }
    sort(res.begin(), res.end());
    while((int)res.size() > a) {
        res.pop_back();
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m, q;
    cin >> n >> m >> q;
    int a,b;
    for(int i = 0; i < n-1; ++i) {
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    for(int i = 1; i <= m; ++i) {
        int node;
        cin >> node;
        value[node].push_back(i);
    }
    for(int i = 1; i <= n; ++i) {
        sort(value[i].begin(), value[i].end());
        if(value[i].size() > 10) value[i].resize(10);
    }
    dfs(1,1);
    for(int i = 1; i <= q; ++i) {
        int u,v,a;
        cin >> u >> v >> a;
        vector<int> res = LCA(u,v,a);
        cout << res.size() << ' ';
        for(int val : res) cout << val << ' ';
        cout << '\n';
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int Max = 1e5+3, Log = 20+1;
vector<int> adj[Max];
int memo[Max][Log];
set<int> st[Max][Log];
int depth[Max];
vector<int> value[Max];

void dfs(int node, int prev, int Depth = 0) {
    depth[node] = Depth;
    memo[node][0] = prev;
    for(int val : value[node]) {
        st[node][0].insert(val);
    }
    while((int)st[node][0].size() > 10) {
        auto it = st[node][0].end();
        --it;
        st[node][0].erase(it);
    }
    for(int i = 1; i < Log; ++i) {
        memo[node][i] = memo[memo[node][i-1]][i-1];
        for(int val : st[node][i-1]) {
            st[node][i].insert(val);
        }
        for(int val : st[memo[node][i-1]][i-1]) {
            st[node][i].insert(val);
        }
        while((int)st[node][i].size() > 10) {
            auto it = st[node][i].end();
            --it;
            st[node][i].erase(it);
        }
    }
    for(int to : adj[node]) {
        if(to == prev) continue;
        dfs(to, node, Depth+1);
    }
}

set<int> LCA(int x, int y, int a) {
    if(depth[x] < depth[y]) swap(x,y);
    int diff = depth[x] - depth[y];
    set<int> res;
    for(int k = Log-1; k >= 0; --k) {
        if(diff&(1<<k)) {
            for(int val : st[x][k]) {
                res.insert(val);
            }
            while((int)res.size() > a) {
                auto it = res.end();
                --it;
                res.erase(it);
            }
            x = memo[x][k];
        }
    }
    for(int k = Log-1; k >= 0; --k) {
        if(memo[x][k] != memo[y][k]) {
            for(int val : st[x][k]) {
                res.insert(val);
            }
            for(int val : st[y][k]) {
                res.insert(val);
            }
            while((int)res.size() > a) {
                auto it = res.end();
                --it;
                res.erase(it);
            }
            x = memo[x][k];
            y = memo[y][k];
        }
    }
    if(x != y) {
        for(int val : st[x][0]) {
            res.insert(val);
        }
        for(int val : st[y][0]) {
            res.insert(val);
        }
        x = memo[x][0];
    }
    while((int)res.size() > a) {
        auto it = res.end();
        --it;
        res.erase(it);
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m, q;
    cin >> n >> m >> q;
    int a,b;
    for(int i = 0; i < n-1; ++i) {
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    for(int i = 1; i <= m; ++i) {
        int node;
        cin >> node;
        value[node].push_back(i);
    }
    dfs(1,1);
    for(int i = 1; i <= q; ++i) {
        int u,v,a;
        cin >> u >> v >> a;
        set<int> res = LCA(u,v,a);
        while(res.size() > a) {
            auto it = res.end();
            --it;
            res.erase(it);
        }
        cout << res.size() << ' ';
        for(int val : res) cout << val << ' ';
        cout << '\n';
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int Max = 1e5+3, Log = 17+1;
vector<int> adj[Max];
int memo[Max][Log];
set<int> st[Max][Log];
int depth[Max];
vector<int> value[Max];

void dfs(int node, int prev, int Depth = 0) {
    depth[node] = Depth;
    memo[node][0] = prev;
    for(int val : value[node]) {
        st[node][0].insert(val);
    }
    while((int)st[node][0].size() > 10) {
        auto it = st[node][0].end();
        --it;
        st[node][0].erase(it);
    }
    for(int i = 1; i < Log; ++i) {
        memo[node][i] = memo[memo[node][i-1]][i-1];
        for(int val : st[node][i-1]) {
            st[node][i].insert(val);
        }
        for(int val : st[memo[node][i-1]][i-1]) {
            st[node][i].insert(val);
        }
        while((int)st[node][i].size() > 10) {
            auto it = st[node][i].end();
            --it;
            st[node][i].erase(it);
        }
    }
    for(int to : adj[node]) {
        if(to == prev) continue;
        dfs(to, node, Depth+1);
    }
}

set<int> LCA(int x, int y, int a) {
    if(depth[x] < depth[y]) swap(x,y);
    int diff = depth[x] - depth[y];
    set<int> res;
    for(int k = Log-1; k >= 0; --k) {
        if(diff&(1<<k)) {
            for(int val : st[x][k]) {
                res.insert(val);
            }
            while((int)res.size() > a) {
                auto it = res.end();
                --it;
                res.erase(it);
            }
            x = memo[x][k];
        }
    }
    for(int k = Log-1; k >= 0; --k) {
        if(memo[x][k] != memo[y][k]) {
            for(int val : st[x][k]) {
                res.insert(val);
            }
            for(int val : st[y][k]) {
                res.insert(val);
            }
            while((int)res.size() > a) {
                auto it = res.end();
                --it;
                res.erase(it);
            }
            x = memo[x][k];
            y = memo[y][k];
        }
    }
    if(x != y) {
        for(int val : st[x][0]) {
            res.insert(val);
        }
        for(int val : st[y][0]) {
            res.insert(val);
        }
        x = memo[x][0];
    }
    for(int val : value[x]) {
        res.insert(val);
    }
    while((int)res.size() > a) {
        auto it = res.end();
        --it;
        res.erase(it);
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m, q;
    cin >> n >> m >> q;
    int a,b;
    for(int i = 0; i < n-1; ++i) {
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    for(int i = 1; i <= m; ++i) {
        int node;
        cin >> node;
        value[node].push_back(i);
    }
    dfs(1,1);
    for(int i = 1; i <= q; ++i) {
        int u,v,a;
        cin >> u >> v >> a;
        set<int> res = LCA(u,v,a);
        while(res.size() > a) {
            auto it = res.end();
            --it;
            res.erase(it);
        }
        cout << res.size() << ' ';
        for(int val : res) cout << val << ' ';
        cout << '\n';
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int Max = 1e5+3, Log = 20+1;
vector<int> adj[Max];
int memo[Max][Log];
set<int> st[Max][Log];
int depth[Max];
vector<int> value[Max];

void dfs(int node, int prev, int Depth = 0) {
    depth[node] = Depth;
    memo[node][0] = prev;
    for(int val : value[node]) {
        st[node][0].insert(val);
    }
    while((int)st[node][0].size() > 10) {
        auto it = st[node][0].end();
        --it;
        st[node][0].erase(it);
    }
    for(int i = 1; i < Log; ++i) {
        memo[node][i] = memo[memo[node][i-1]][i-1];
        for(int val : st[node][i-1]) {
            st[node][i].insert(val);
        }
        for(int val : st[memo[node][i-1]][i-1]) {
            st[node][i].insert(val);
        }
        while((int)st[node][i].size() > 10) {
            auto it = st[node][i].end();
            --it;
            st[node][i].erase(it);
        }
    }
    for(int to : adj[node]) {
        if(to == prev) continue;
        dfs(to, node, Depth+1);
    }
}

set<int> LCA(int x, int y, int a) {
    if(depth[x] < depth[y]) swap(x,y);
    int diff = depth[x] - depth[y];
    set<int> res;
    for(int k = Log-1; k >= 0; --k) {
        if(diff&(1<<k)) {
            for(int val : st[x][k]) {
                res.insert(val);
            }
            while((int)res.size() > a) {
                auto it = res.end();
                --it;
                res.erase(it);
            }
            x = memo[x][k];
        }
    }
    for(int k = Log-1; k >= 0; --k) {
        if(memo[x][k] != memo[y][k]) {
            for(int val : st[x][k]) {
                res.insert(val);
            }
            for(int val : st[y][k]) {
                res.insert(val);
            }
            while((int)res.size() > a) {
                auto it = res.end();
                --it;
                res.erase(it);
            }
            x = memo[x][k];
            y = memo[y][k];
        }
    }
    if(x != y) {
        for(int val : st[x][0]) {
            res.insert(val);
        }
        for(int val : st[y][0]) {
            res.insert(val);
        }
        x = memo[x][0];
    }
    for(int val : value[x]) {
        res.insert(val);
    }
    while((int)res.size() > a) {
        auto it = res.end();
        --it;
        res.erase(it);
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m, q;
    cin >> n >> m >> q;
    int a,b;
    for(int i = 0; i < n-1; ++i) {
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    for(int i = 1; i <= m; ++i) {
        int node;
        cin >> node;
        value[node].push_back(i);
    }
    dfs(1,1);
    for(int i = 1; i <= q; ++i) {
        int u,v,a;
        cin >> u >> v >> a;
        set<int> res = LCA(u,v,a);
        while(res.size() > a) {
            auto it = res.end();
            --it;
            res.erase(it);
        }
        cout << res.size() << ' ';
        for(int val : res) cout << val << ' ';
        cout << '\n';
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int Max = 1e5+3, Log = 17+1;
vector<int> adj[Max];
int memo[Max][Log];
set<int> st[Max][Log];
int depth[Max];
vector<int> value[Max];

void dfs(int node, int prev, int Depth = 0) {
    depth[node] = Depth;
    memo[node][0] = prev;
    for(int val : value[node]) {
        st[node][0].insert(val);
    }
    while((int)st[node][0].size() > 10) {
        auto it = st[node][0].end();
        --it;
        st[node][0].erase(it);
    }
    for(int i = 1; i < Log; ++i) {
        memo[node][i] = memo[memo[node][i-1]][i-1];
        for(int val : st[node][i-1]) {
            st[node][i].insert(val);
        }
        for(int val : st[memo[node][i-1]][i-1]) {
            st[node][i].insert(val);
        }
        while((int)st[node][i].size() > 10) {
            auto it = st[node][i].end();
            --it;
            st[node][i].erase(it);
        }
    }
    for(int to : adj[node]) {
        if(to == prev) continue;
        dfs(to, node, Depth+1);
    }
}

set<int> LCA(int x, int y, int a) {
    if(depth[x] < depth[y]) swap(x,y);
    int diff = depth[x] - depth[y];
    set<int> res;
    for(int k = Log-1; k >= 0; --k) {
        if(diff&(1<<k)) {
            for(int val : st[x][k]) {
                res.insert(val);
            }
            while((int)res.size() > a) {
                auto it = res.end();
                --it;
                res.erase(it);
            }
            x = memo[x][k];
        }
    }
    for(int k = Log-1; k >= 0; --k) {
        if(memo[x][k] != memo[y][k]) {
            for(int val : st[x][k]) {
                res.insert(val);
            }
            for(int val : st[y][k]) {
                res.insert(val);
            }
            while((int)res.size() > a) {
                auto it = res.end();
                --it;
                res.erase(it);
            }
            x = memo[x][k];
            y = memo[y][k];
        }
    }
    if(x != y) {
        for(int val : st[x][0]) {
            res.insert(val);
        }
        for(int val : st[y][0]) {
            res.insert(val);
        }
        x = memo[x][0];
    }
    while((int)res.size() > a) {
        auto it = res.end();
        --it;
        res.erase(it);
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m, q;
    cin >> n >> m >> q;
    int a,b;
    for(int i = 0; i < n-1; ++i) {
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    for(int i = 1; i <= m; ++i) {
        int node;
        cin >> node;
        value[node].push_back(i);
    }
    dfs(1,1);
    for(int i = 1; i <= q; ++i) {
        int u,v,a;
        cin >> u >> v >> a;
        set<int> res = LCA(u,v,a);
        while(res.size() > a) {
            auto it = res.end();
            --it;
            res.erase(it);
        }
        cout << res.size() << ' ';
        for(int val : res) cout << val << ' ';
        cout << '\n';
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int Max = 1e5+3, Log = 17+1;
vector<int> adj[Max];
int memo[Max][Log];
vector<int> st[Max][Log];
int depth[Max];
vector<int> value[Max];

void dfs(int node, int prev, int Depth = 0) {
    depth[node] = Depth;
    memo[node][0] = prev;
    vector<int> &temp = st[node][0];
    for(int val : value[node]) {
        temp.push_back(val);
    }
    sort(temp.begin(), temp.end());
    if(temp.size() > 10) temp.resize(10);
    for(int i = 1; i < Log; ++i) {
        memo[node][i] = memo[memo[node][i-1]][i-1];
        vector<int> &temp2 = st[node][i];
        for(int &val : st[node][i-1]) {
            temp2.push_back(val);
        }
        for(int &val : st[memo[node][i-1]][i-1]) {
            temp2.push_back(val);
        }
        sort(temp2.begin(), temp2.end());
        if((int)temp2.size() > 10) {
            temp2.resize(10);
        }
    }
    for(int to : adj[node]) {
        if(to == prev) continue;
        dfs(to, node, Depth+1);
    }
}

vector<int> LCA(int x, int y, int a) {
    if(depth[x] < depth[y]) swap(x,y);
    int diff = depth[x] - depth[y];
    vector<int> res;
    for(int k = Log-1; k >= 0; --k) {
        if(diff&(1<<k)) {
            for(int &val : st[x][k]) {
                res.push_back(val);
            }
            x = memo[x][k];
        }
    }
    for(int k = Log-1; k >= 0; --k) {
        if(memo[x][k] != memo[y][k]) {
            for(int &val : st[x][k]) {
                res.push_back(val);
            }
            for(int &val : st[y][k]) {
                res.push_back(val);
            }
            x = memo[x][k];
            y = memo[y][k];
        }
    }
    if(x != y) {
        for(int &val : st[x][0]) {
            res.push_back(val);
        }
        for(int &val : st[y][0]) {
            res.push_back(val);
        }
        x = memo[x][0];
    }
    for(int &val : value[x]) {
        res.push_back(val);
    }
    sort(res.begin(), res.end());
    while((int)res.size() > a) {
        res.pop_back();
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m, q;
    cin >> n >> m >> q;
    int a,b;
    for(int i = 0; i < n-1; ++i) {
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    for(int i = 1; i <= m; ++i) {
        int node;
        cin >> node;
        value[node].push_back(i);
    }
    dfs(1,1);
    for(int i = 1; i <= q; ++i) {
        int u,v,a;
        cin >> u >> v >> a;
        vector<int> res = LCA(u,v,a);
        cout << res.size() << ' ';
        for(int val : res) cout << val << ' ';
        cout << '\n';
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int Max = 1e5+3, Log = 18+1;
vector<int> adj[Max];
int memo[Max][Log];
vector<int> st[Max][Log];
int depth[Max];
vector<int> value[Max];

void dfs(int node, int prev, int Depth = 0) {
    depth[node] = Depth;
    memo[node][0] = prev;
    for(int val : value[node]) {
        st[node][0].push_back(val);
    }
    sort(st[node][0].begin(), st[node][0].end());
    while((int)st[node][0].size() > 10) {
        st[node][0].pop_back();
    }
    for(int i = 1; i < Log; ++i) {
        memo[node][i] = memo[memo[node][i-1]][i-1];
        for(int val : st[node][i-1]) {
            st[node][i].push_back(val);
        }
        for(int val : st[memo[node][i-1]][i-1]) {
            st[node][i].push_back(val);
        }
        sort(st[node][i].begin(), st[node][i].end());
        while((int)st[node][i].size() > 10) {
            st[node][i].pop_back();
        }
    }
    for(int to : adj[node]) {
        if(to == prev) continue;
        dfs(to, node, Depth+1);
    }
}

vector<int> LCA(int x, int y, int a) {
    if(depth[x] < depth[y]) swap(x,y);
    int diff = depth[x] - depth[y];
    vector<int> res;
    for(int k = Log-1; k >= 0; --k) {
        if(diff&(1<<k)) {
            for(int val : st[x][k]) {
                res.push_back(val);
            }
            x = memo[x][k];
        }
    }
    for(int k = Log-1; k >= 0; --k) {
        if(memo[x][k] != memo[y][k]) {
            for(int val : st[x][k]) {
                res.push_back(val);
            }
            for(int val : st[y][k]) {
                res.push_back(val);
            }
            x = memo[x][k];
            y = memo[y][k];
        }
    }
    if(x != y) {
        for(int val : st[x][0]) {
            res.push_back(val);
        }
        for(int val : st[y][0]) {
            res.push_back(val);
        }
        x = memo[x][0];
    }
    for(int val : value[x]) {
        res.push_back(val);
    }
    sort(res.begin(), res.end());
    while((int)res.size() > a) {
        res.pop_back();
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m, q;
    cin >> n >> m >> q;
    int a,b;
    for(int i = 0; i < n-1; ++i) {
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    for(int i = 1; i <= m; ++i) {
        int node;
        cin >> node;
        value[node].push_back(i);
    }
    dfs(1,1);
    for(int i = 1; i <= q; ++i) {
        int u,v,a;
        cin >> u >> v >> a;
        vector<int> res = LCA(u,v,a);
        cout << res.size() << ' ';
        for(int val : res) cout << val << ' ';
        cout << '\n';
    }
    return 0;
}


#include <iostream>
#include <cmath>
#include <cctype>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <stack>
#include <unordered_set>
#include <sstream>
#include <cstring>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <random>
#include <cfloat>

struct List {
	int32_t items[10];
	int32_t size;

	List() : size(0) {

	}

	List(int32_t val) : size(1) {
		items[0] = val;
	}

	void merge(List other) {
		int32_t new_items[20];
		int32_t p1 = 0, p2 = 0;
		for(int32_t i = 0 ;i < size + other.size; i++) {
			if (p1 == size) {
				new_items[p1 + p2] = other.items[p2];
				p2++;
			} else if (p2 == other.size) {
				new_items[p1 + p2] = items[p1];
				p1++;
			} else if(items[p1] < other.items[p2]) {
				new_items[p1 + p2] = items[p1];
				p1++;
			} else {
				new_items[p1 + p2] = other.items[p2];
				p2++;
			}
		}
		for(int32_t i = 0 ; i < 10; i++)
			items[i] = new_items[i];
		size = std::min(10, p1 + p2);
	}
};

int32_t* tin, *tout;
int32_t timer = 0;
void dfs(int32_t vertex, std::pair<int32_t, List>** ancestors, int32_t parent, std::vector<int32_t>* tree, List* vertex_lists) {
	ancestors[vertex] = new std::pair<int32_t, List>[20];
	ancestors[vertex][0] = {vertex, vertex_lists[vertex]};
	ancestors[vertex][1] = {parent, parent == -1 ? List() : vertex_lists[parent]};
	for(int32_t i = 2; i < 20; i++)
		if(ancestors[vertex][i - 1].first == -1) {
			ancestors[vertex][i] = {-1, List()};
		} else {
			ancestors[vertex][i] = ancestors[ancestors[vertex][i - 1].first][i - 1];
			ancestors[vertex][i].second.merge(ancestors[ancestors[vertex][i - 1].first][i - 1].second);
		}
	tin[vertex] = timer++;
	for(int32_t i = 0 ; i  < tree[vertex].size(); i++)
		if(tree[vertex][i] != parent)
			dfs(tree[vertex][i], ancestors, vertex, tree, vertex_lists);
	tout[vertex] = timer;
}

bool is_ancestor(int32_t v1, int32_t v2) {
	return tin[v1] <= tin[v2] && tout[v1] >= tout[v2];
}

List get_ans(int32_t u, int32_t v, std::pair<int32_t, List>** ancestors) {
	bool vertical = is_ancestor(v, u) || is_ancestor(u, v);

	List ans = ancestors[u][0].second;
	if(u != v)
		ans.merge(ancestors[v][0].second);

	int32_t cur = u;
	while(true) {
		int32_t ind_next = 0;
		while(ancestors[cur][ind_next + 1].first != -1 && !is_ancestor(ancestors[cur][ind_next + 1].first, v))
			ind_next++;
		if(ind_next == 0) {
			if(!vertical && ancestors[cur][1].first != -1 && is_ancestor(ancestors[cur][1].first, v))
				ans.merge(ancestors[cur][1].second);
			break;
		}

		ans.merge(ancestors[cur][ind_next].second);
		cur = ancestors[cur][ind_next].first;
	}

	cur = v;
	while(true) {
		int32_t ind_next = 0;
		while(ancestors[cur][ind_next + 1].first != -1 && !is_ancestor(ancestors[cur][ind_next + 1].first, u))
			ind_next++;
		if(ind_next == 0) {
			//ans.merge(ancestors[cur][0].second);
			break;
		}

		ans.merge(ancestors[cur][ind_next].second);
		cur = ancestors[cur][ind_next].first;
	}

	return ans;
}

int main() {
	int32_t n, m, num_queries;
	std::cin >> n >> m >> num_queries;

	std::vector<int32_t>* tree = new std::vector<int32_t>[n];
	for(int32_t i = 0 ; i  < n - 1; i++) {
		int32_t src, dst;
		std::cin >> src >> dst;
		src--;
		dst--;

		tree[src].push_back(dst);
		tree[dst].push_back(src);
	}

	List* vertex_lists = new List[n];
	for(int32_t i = 0 ;i  < m; i++) {
		int32_t ind;
		std::cin >> ind;
		ind--;

		vertex_lists[ind].merge(List(i));
	}
	std::pair<int32_t, List>** ancestors = new std::pair<int32_t, List>*[n];
	tin =  new int32_t[n];
	tout = new int32_t[n];
	dfs(0, ancestors, -1, tree, vertex_lists);

	for(int32_t q = 0; q < num_queries; q++) {
		int32_t u, v, num;
		std::cin >> u >> v >> num;
		u--;
		v--;

		List list = get_ans(u, v, ancestors);
		std::cout << std::min(list.size, num) << " ";
		for(int32_t i = 0 ; i < std::min(list.size, num); i++)
			std::cout << list.items[i] + 1 << " ";
		std::cout << "\n";
	}
	return 0;

};


#include <iostream>
#include <cmath>
#include <cctype>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <stack>
#include <unordered_set>
#include <sstream>
#include <cstring>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <random>
#include <cfloat>

struct List {
	int32_t items[10];
	int32_t size;

	List() : size(0) {

	}

	List(int32_t val) : size(1) {
		items[0] = val;
	}

	void merge(List other) {
		int32_t new_items[20];
		int32_t p1 = 0, p2 = 0;
		for(int32_t i = 0 ;i < size + other.size; i++) {
			if (p1 == size) {
				new_items[p1 + p2] = other.items[p2];
				p2++;
			} else if (p2 == other.size) {
				new_items[p1 + p2] = items[p1];
				p1++;
			} else if(items[p1] < other.items[p2]) {
				new_items[p1 + p2] = items[p1];
				p1++;
			} else {
				new_items[p1 + p2] = other.items[p2];
				p2++;
			}
		}
		for(int32_t i = 0 ; i < 10; i++)
			items[i] = new_items[i];
		size = std::min(10, p1 + p2);
	}
};

int32_t* tin, *tout;
int32_t timer = 0;
void dfs(int32_t vertex, std::pair<int32_t, List>** ancestors, int32_t parent, std::vector<int32_t>* tree, List* vertex_lists) {
	ancestors[vertex] = new std::pair<int32_t, List>[20];
	ancestors[vertex][0] = {vertex, vertex_lists[vertex]};
	ancestors[vertex][1] = {parent, parent == -1 ? List() : vertex_lists[parent]};
	for(int32_t i = 2; i < 20; i++)
		if(ancestors[vertex][i - 1].first == -1) {
			ancestors[vertex][i] = {-1, List()};
		} else {
			ancestors[vertex][i] = ancestors[ancestors[vertex][i - 1].first][i - 1];
			ancestors[vertex][i].second.merge(ancestors[vertex][i - 1].second);
		}
	tin[vertex] = timer++;
	for(int32_t i = 0 ; i  < tree[vertex].size(); i++)
		if(tree[vertex][i] != parent)
			dfs(tree[vertex][i], ancestors, vertex, tree, vertex_lists);
	tout[vertex] = timer;
}

bool is_ancestor(int32_t v1, int32_t v2) {
	return tin[v1] <= tin[v2] && tout[v1] >= tout[v2];
}

List get_ans(int32_t u, int32_t v, std::pair<int32_t, List>** ancestors) {
	bool vertical = is_ancestor(v, u) || is_ancestor(u, v);

	List ans = ancestors[u][0].second;
	if(u != v)
		ans.merge(ancestors[v][0].second);

	int32_t cur = u;
	while(true) {
		int32_t ind_next = 0;
		while(ancestors[cur][ind_next + 1].first != -1 && !is_ancestor(ancestors[cur][ind_next + 1].first, v))
			ind_next++;
		if(ind_next == 0) {
			if(!vertical && ancestors[cur][1].first != -1 && is_ancestor(ancestors[cur][1].first, v))
				ans.merge(ancestors[cur][1].second);
			break;
		}

		ans.merge(ancestors[cur][ind_next].second);
		cur = ancestors[cur][ind_next].first;
	}

	cur = v;
	while(true) {
		int32_t ind_next = 0;
		while(ancestors[cur][ind_next + 1].first != -1 && !is_ancestor(ancestors[cur][ind_next + 1].first, u))
			ind_next++;
		if(ind_next == 0) {
			//ans.merge(ancestors[cur][0].second);
			break;
		}

		ans.merge(ancestors[cur][ind_next].second);
		cur = ancestors[cur][ind_next].first;
	}

	return ans;
}

int main() {
	int32_t n, m, num_queries;
	std::cin >> n >> m >> num_queries;

	std::vector<int32_t>* tree = new std::vector<int32_t>[n];
	for(int32_t i = 0 ; i  < n - 1; i++) {
		int32_t src, dst;
		std::cin >> src >> dst;
		src--;
		dst--;

		tree[src].push_back(dst);
		tree[dst].push_back(src);
	}

	List* vertex_lists = new List[n];
	for(int32_t i = 0 ;i  < m; i++) {
		int32_t ind;
		std::cin >> ind;
		ind--;

		vertex_lists[ind].merge(List(i));
	}
	std::pair<int32_t, List>** ancestors = new std::pair<int32_t, List>*[n];
	tin =  new int32_t[n];
	tout = new int32_t[n];
	dfs(0, ancestors, -1, tree, vertex_lists);

	for(int32_t q = 0; q < num_queries; q++) {
		int32_t u, v, num;
		std::cin >> u >> v >> num;
		u--;
		v--;

		List list = get_ans(u, v, ancestors);
		std::cout << std::min(list.size, num) << " ";
		for(int32_t i = 0 ; i < std::min(list.size, num); i++)
			std::cout << list.items[i] + 1 << " ";
		std::cout << "\n";
	}
	return 0;

};


#include <iostream>
#include <cmath>
#include <cctype>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <stack>
#include <unordered_set>
#include <sstream>
#include <cstring>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <random>
#include <cfloat>

struct List {
	int32_t items[10];
	int32_t size;

	List() : size(0) {

	}

	List(int32_t val) : size(1) {
		items[0] = val;
	}

	void merge(List other) {
		int32_t new_items[20];
		int32_t p1 = 0, p2 = 0;
		for(int32_t i = 0 ;i < size + other.size; i++) {
			if (p1 == size) {
				new_items[p1 + p2] = other.items[p2];
				p2++;
			} else if (p2 == other.size) {
				new_items[p1 + p2] = items[p1];
				p1++;
			} else if(items[p1] < other.items[p2]) {
				new_items[p1 + p2] = items[p1];
				p1++;
			} else {
				new_items[p1 + p2] = other.items[p2];
				p2++;
			}
		}
		for(int32_t i = 0 ; i < 10; i++)
			items[i] = new_items[i];
		size = std::min(10, p1 + p2);
	}
};

int32_t* tin, *tout;
int32_t timer = 0;
void dfs(int32_t vertex, std::pair<int32_t, List>** ancestors, int32_t parent, std::vector<int32_t>* tree, List* vertex_lists) {
	ancestors[vertex] = new std::pair<int32_t, List>[20];
	ancestors[vertex][0] = {vertex, vertex_lists[vertex]};
	ancestors[vertex][1] = {parent, parent == -1 ? List() : vertex_lists[parent]};
	for(int32_t i = 2; i < 20; i++)
		if(ancestors[vertex][i - 1].first == -1) {
			ancestors[vertex][i] = {-1, List()};
		} else {
			ancestors[vertex][i] = ancestors[ancestors[vertex][i - 1].first][i - 1];
			ancestors[vertex][i].second.merge(ancestors[ancestors[vertex][i - 1].first][i - 1].second);
		}
	tin[vertex] = timer++;
	for(int32_t i = 0 ; i  < tree[vertex].size(); i++)
		if(tree[vertex][i] != parent)
			dfs(tree[vertex][i], ancestors, vertex, tree, vertex_lists);
	tout[vertex] = timer;
}

bool is_ancestor(int32_t v1, int32_t v2) {
	return tin[v1] <= tin[v2] && tout[v1] >= tout[v2];
}

List get_ans(int32_t u, int32_t v, std::pair<int32_t, List>** ancestors) {
	bool vertical = is_ancestor(v, u) || is_ancestor(u, v);

	List ans = ancestors[u][0].second;
	ans.merge(ancestors[v][0].second);

	int32_t cur = u;
	while(true) {
		int32_t ind_next = 0;
		while(ancestors[cur][ind_next + 1].first != -1 && !is_ancestor(ancestors[cur][ind_next + 1].first, v))
			ind_next++;
		if(ind_next == 0) {
			if(!vertical && ancestors[cur][1].first != -1 && is_ancestor(ancestors[cur][1].first, v))
				ans.merge(ancestors[cur][1].second);
			break;
		}

		ans.merge(ancestors[cur][ind_next].second);
		cur = ancestors[cur][ind_next].first;
	}

	cur = v;
	while(true) {
		int32_t ind_next = 0;
		while(ancestors[cur][ind_next + 1].first != -1 && !is_ancestor(ancestors[cur][ind_next + 1].first, u))
			ind_next++;
		if(ind_next == 0) {
			//ans.merge(ancestors[cur][0].second);
			break;
		}

		ans.merge(ancestors[cur][ind_next].second);
		cur = ancestors[cur][ind_next].first;
	}

	return ans;
}

int main() {
	int32_t n, m, num_queries;
	std::cin >> n >> m >> num_queries;

	std::vector<int32_t>* tree = new std::vector<int32_t>[n];
	for(int32_t i = 0 ; i  < n - 1; i++) {
		int32_t src, dst;
		std::cin >> src >> dst;
		src--;
		dst--;

		tree[src].push_back(dst);
		tree[dst].push_back(src);
	}

	List* vertex_lists = new List[n];
	for(int32_t i = 0 ;i  < m; i++) {
		int32_t ind;
		std::cin >> ind;
		ind--;

		vertex_lists[ind].merge(List(i));
	}
	std::pair<int32_t, List>** ancestors = new std::pair<int32_t, List>*[n];
	tin =  new int32_t[n];
	tout = new int32_t[n];
	dfs(0, ancestors, -1, tree, vertex_lists);

	for(int32_t q = 0; q < num_queries; q++) {
		int32_t u, v, num;
		std::cin >> u >> v >> num;
		u--;
		v--;

		List list = get_ans(u, v, ancestors);
		std::cout << std::min(list.size, num) << " ";
		for(int32_t i = 0 ; i < std::min(list.size, num); i++)
			std::cout << list.items[i] + 1 << " ";
		std::cout << "\n";
	}
	return 0;

};


#include<bits/stdc++.h>
using namespace std;

const int N = 1e5 + 10, LOG = 20;
int par[N][LOG], h[N];
vector<int> adj[N], vec[N][LOG];

vector<int> merge(vector<int> v1, vector<int> v2) {
    vector<int> res;
    int a = 0, b = 0;
    while (a < v1.size() && b < v2.size()) {
        if (v1[a] < v2[b]) {
            res.push_back(v1[a]);
            a++;
        }
        else {
            res.push_back(v2[b]);
            b++;
        }
    }
    while (a < v1.size()) {
        res.push_back(v1[a]);
        a++;
    }
    while (b < v2.size()) {
        res.push_back(v2[b]);
        b++;
    }
    return res;
}

void dfs(int u, int parr) {
    h[u] = (parr ^ -1? h[parr] + 1: 0);
    par[u][0] = parr;
    for (int i = 1; i < LOG; i++) {
        par[u][i] = (par[u][i - 1] ^ -1? par[par[u][i - 1]][i - 1]: -1);
        if (par[u][i] ^ -1)
            vec[u][i] = merge(vec[u][i - 1], vec[par[u][i - 1]][i - 1]);
    }
    for (auto v: adj[u])
        if (v ^ parr)
            dfs(v, u);
    return;
}

int get_par(int u, int k) {
    for (int i = LOG - 1; ~i; i--)
        if (k & (1 << i))
            u = par[u][i];
    return u;
}

int lca(int u, int v) {
    if (h[u] < h[v])
        swap(u, v);
    u = get_par(u, h[u] - h[v]);
    if (u == v)
        return u;
    for (int i = LOG - 1; ~i; i--)
        if (par[u][i] != par[v][i]) {
            u = par[u][i];
            v = par[v][i];
        }
    return par[u][0];
}

vector<int> get_vec(int u, int k) {
    vector<int> res;
    for (int i = LOG - 1; ~i; i--)
        if (k & (1 << i))
            res = merge(res, vec[u][i]);
    return res;
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n, m, q, u, v, c, a;
    cin >> n >> m >> q;
    for (int i = 1; i < n; i++) {
        cin >> u >> v;
        adj[--u].push_back(--v);
        adj[v].push_back(u);
    }
    for (int i = 0; i < m; i++) {
        cin >> c;
        if (vec[--c][0].size() < 10)
            vec[c][0].push_back(i);
    }
    dfs(0, -1);
    while (q--) {
        cin >> u >> v >> a;
        int x = lca(--u, --v);
        vector<int> ans = merge(merge(get_vec(u, h[u] - h[x]), get_vec(v, h[v] - h[x])), vec[x][0]);
        cout << min((int)ans.size(), a) << " ";
        for (int i = 0; i < min((int)ans.size(), a); i++)
            cout << ans[i] + 1 << " ";
        cout << "\n";
    }
}


#include<bits/stdc++.h>
using namespace std;

const int N = 1e5 + 10, LOG = 20;
int par[N][LOG], h[N];
vector<int> adj[N], vec[N][LOG];

void dfs(int u, int parr) {
    h[u] = (parr ^ -1? h[parr] + 1: 0);
    par[u][0] = parr;
    for (int i = 1; i < LOG; i++) {
        par[u][i] = (par[u][i - 1] ^ -1? par[par[u][i - 1]][i - 1]: -1);
        if (par[u][i] ^ -1) {
            vec[u][i] = vec[u][i - 1];
            for (auto x: vec[par[u][i - 1]][i - 1])
                vec[u][i].push_back(x);
            sort(vec[u][i].begin(), vec[u][i].end());
            while (vec[u][i].size() > 10)
                vec[u][i].pop_back();
        }
    }
    for (auto v: adj[u])
        if (v ^ parr)
            dfs(v, u);
    return;
}

int get_par(int u, int k) {
    for (int i = LOG - 1; ~i; i--)
        if (k & (1 << i))
            u = par[u][i];
    return u;
}

int lca(int u, int v) {
    if (h[u] < h[v])
        swap(u, v);
    u = get_par(u, h[u] - h[v]);
    if (u == v)
        return u;
    for (int i = LOG - 1; ~i; i--)
        if (par[u][i] != par[v][i]) {
            u = par[u][i];
            v = par[v][i];
        }
    return par[u][0];
}

vector<int> get_vec(int u, int k) {
    vector<int> res;
    for (int i = LOG - 1; ~i; i--)
        if (k & (1 << i)) {
            for (auto x: vec[u][i])
                res.push_back(x);
            sort(res.begin(), res.end());
            while (res.size() > 10)
                res.pop_back();
            u = par[u][i];
        }
    return res;
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n, m, q, u, v, c, a;
    cin >> n >> m >> q;
    for (int i = 1; i < n; i++) {
        cin >> u >> v;
        adj[--u].push_back(--v);
        adj[v].push_back(u);
    }
    for (int i = 0; i < m; i++) {
        cin >> c;
        if (vec[--c][0].size() < 10)
            vec[c][0].push_back(i);
    }
    dfs(0, -1);
    while (q--) {
        cin >> u >> v >> a;
        int x = lca(--u, --v);
        vector<int> ans = vec[x][0];
        for (auto x: get_vec(u, h[u] - h[x]))
            ans.push_back(x);
        for (auto x: get_vec(v, h[v] - h[x]))
            ans.push_back(x);
        sort(ans.begin(), ans.end());
        while (ans.size() > a)
            ans.pop_back();
        cout << min((int)ans.size(), a) << " ";
        for (int i = 0; i < min((int)ans.size(), a); i++)
            cout << ans[i] + 1 << " ";
        cout << "\n";
    }
}


#include<bits/stdc++.h>
using namespace std;

const int N = 1e5 + 10, LOG = 20;
int par[N][LOG], h[N];
vector<int> adj[N], vec[N][LOG];

vector<int> merge(vector<int> &v1, vector<int> &v2) {
    vector<int> res;
    int a = 0, b = 0;
    while (a < v1.size() && b < v2.size()) {
        if (v1[a] < v2[b]) {
            res.push_back(v1[a]);
            a++;
        }
        else {
            res.push_back(v2[b]);
            b++;
        }
    }
    while (a < v1.size()) {
        res.push_back(v1[a]);
        a++;
    }
    while (b < v2.size()) {
        res.push_back(v2[b]);
        b++;
    }
    return res;
}

void dfs(int u, int parr) {
    h[u] = (parr ^ -1? h[parr] + 1: 0);
    par[u][0] = parr;
    for (int i = 1; i < LOG; i++) {
        par[u][i] = (par[u][i - 1] ^ -1? par[par[u][i - 1]][i - 1]: -1);
        if (par[u][i] ^ -1)
            vec[u][i] = merge(vec[u][i - 1], vec[par[u][i - 1]][i - 1]);
    }
    for (auto v: adj[u])
        if (v ^ parr)
            dfs(v, u);
    return;
}

int get_par(int u, int k) {
    for (int i = LOG - 1; ~i; i--)
        if (k & (1 << i))
            u = par[u][i];
    return u;
}

int lca(int u, int v) {
    if (h[u] < h[v])
        swap(u, v);
    u = get_par(u, h[u] - h[v]);
    if (u == v)
        return u;
    for (int i = LOG - 1; ~i; i--)
        if (par[u][i] != par[v][i]) {
            u = par[u][i];
            v = par[v][i];
        }
    return par[u][0];
}

vector<int> get_vec(int u, int k) {
    vector<int> res;
    for (int i = LOG - 1; ~i; i--)
        if (k & (1 << i)) {
            res = merge(res, vec[u][i]);
            u = par[u][i];
        }
    return res;
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n, m, q, u, v, c, a;
    cin >> n >> m >> q;
    for (int i = 1; i < n; i++) {
        cin >> u >> v;
        adj[--u].push_back(--v);
        adj[v].push_back(u);
    }
    for (int i = 0; i < m; i++) {
        cin >> c;
        if (vec[--c][0].size() < 10)
            vec[c][0].push_back(i);
    }
    dfs(0, -1);
    while (q--) {
        cin >> u >> v >> a;
        int x = lca(--u, --v);
        vector<int> ans = merge(merge(get_vec(u, h[u] - h[x]), get_vec(v, h[v] - h[x])), vec[x][0]);
        cout << min((int)ans.size(), a) << " ";
        for (int i = 0; i < min((int)ans.size(), a); i++)
            cout << ans[i] + 1 << " ";
        cout << "\n";
    }
}