//tonynater - HackerRank 2014
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
#define sz(x) ((int) x.size())
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
const double pi = acos(-1);
const double tau = 2*pi;
const double epsilon = 1e-6;
const int MAX_N = 100100;
int N, M, R;
vector<int> adj[MAX_N];
int color[MAX_N];
vector<int> children[MAX_N];
void root(int u, int parent)
{
for(int i = 0; i < sz(adj[u]); i++)
if(adj[u][i] != parent)
{
root(adj[u][i], u);
children[u].push_back(adj[u][i]);
}
}
vector<int> inorder;
void order(int u)
{
for(int i = 0; i < sz(children[u]); i++)
order(children[u][i]);
inorder.push_back(u);
}
int nDistinct[MAX_N];
int idx[MAX_N];
set<int> subtree[MAX_N];
void countElements(int u)
{
int mxChild = 0, big = u;
for(int i = 0; i < sz(children[u]); i++)
if(sz(subtree[idx[children[u][i]]]) > mxChild)
{
mxChild = sz(subtree[idx[children[u][i]]]);
big = idx[children[u][i]];
}
for(int i = 0; i < sz(children[u]); i++)
if(idx[children[u][i]] != big)
{
for(set<int>::const_iterator it = subtree[idx[children[u][i]]].begin(); it != subtree[idx[children[u][i]]].end(); it++)
subtree[big].insert(*it);
subtree[idx[children[u][i]]].clear();
}
subtree[big].insert(color[u]);
nDistinct[u] = sz(subtree[big]);
idx[u] = big;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cin >> N >> M >> R;
--R;
for(int i = 0; i < N-1; i++)
{
int u, v;
cin >> u >> v;
--u; --v;
adj[u].push_back(v);
adj[v].push_back(u);
}
for(int i = 0; i < N; i++)
cin >> color[i];
root(R, -1);
order(R);
for(int i = 0; i < sz(inorder); i++)
countElements(inorder[i]);
for(int i = 0; i < M; i++)
{
int s;
cin >> s;
--s;
cout << nDistinct[s] << '\n';
}
return 0;
}