Problem: Alice and Bob are playing a game. They have a tree consisting of n vertices. Initially, Bob has k chips, the i-th chip is located in the vertex a_i (all these vertices are unique). Before the game starts, Alice will place a chip into one of the vertices of the tree.

The game consists of turns. Each turn, the following events happen (sequentially, exactly in the following order):

  1. Alice either moves her chip to an adjacent vertex or doesn't move it; 
  2. for each Bob's chip, he either moves it to an adjacent vertex or doesn't move it. Note that this choice is done independently for each chip. 



The game ends when Alice's chip shares the same vertex with one (or multiple) of Bob's chips. Note that Bob's chips may share the same vertex, even though they are in different vertices at the beginning of the game.

Alice wants to maximize the number of turns, Bob wants to minimize it. If the game ends in the middle of some turn (Alice moves her chip to a vertex that contains one or multiple Bob's chips), this turn is counted.

For each vertex, calculate the number of turns the game will last if Alice places her chip in that vertex.

Input

The first line contains one integer n (2 ≤ n ≤ 2 ⋅ 10^5) — the number of vertices in the tree.

Then n - 1 lines follow, each line contains two integers u_i, v_i (1 ≤ u_i, v_i ≤ n; u_i ≠ v_i) that denote the endpoints of an edge. These edges form a tree.

The next line contains one integer k (1 ≤ k ≤ n - 1) — the number of Bob's chips.

The last line contains k integers a_1, a_2, ..., a_k (1 ≤ a_i ≤ n; a_i ≠ a_j if i ≠ j) — the vertices where the Bob's chips are initially placed.

Output

Print n integers. The i-th of them should be equal to the number of turns the game will last if Alice initially places her chip in the vertex i. If one of Bob's chips is already placed in vertex i, then the answer for vertex i is 0.

Examples

Input


5
2 4
3 1
3 4
3 5
2
4 5


Output


2 1 2 0 0


Input


8
4 1
8 4
4 5
6 4
2 5
4 3
1 7
3
2 8 3


Output


3 0 0 3 1 2 3 0


Input


10
2 5
4 3
7 3
7 2
5 8
3 6
8 10
7 9
7 1
4
10 6 9 1


Output


0 2 2 2 2 0 2 2 0 0

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
#define maxn 200005
#define mp std::make_pair
#define pii std::pair<int,int>

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const int inf = 1e8;

int size[maxn],n,a[maxn],k,dis[maxn],vis[maxn],rt,u,v,ans[maxn];
std::queue<int>q;
std::vector<pii>vec[maxn];
std::vector<int>ch[maxn];
std::vector<pii>S[maxn];

void dfsp(int u,int f=0){
	size[u]=1;
	for(int v:ch[u]){
		if(v==f||vis[v])continue;
		dfsp(v,u);
		size[u]+=size[v];
	}
}

void get_rt(int x,int f,int sum){
	int w=sum-size[x];
	for (int v:ch[x]){
		if(v==f||vis[v])continue;
		get_rt(v,x,sum);
		w=std::max(w,size[v]);
	}if(w<=sum/2)rt=x;
}

void dfs1(int u,int f,int dp,int to) {
	if (dis[u]-dp>0){
		ans[to]=std::max(ans[to],dis[u]);
		vec[to].push_back(mp(dis[u]-dp,dis[u]));
	}
	for (int v:ch[u]){
		if(v==f||vis[v])continue;
		dfs1(v,u,dp+1,to);
	}
}

void dfs2(int u,int f,int to,int d,int lim) {
	if (d >= lim || dis[u] == 0) return;
	auto p = std::upper_bound(S[to].begin(),S[to].end(),mp(d,inf));/// p--;
	//if (u ==4 && to == 1) { printf("->%d %d\n",d,(*p).second); }
	ans[u]=std::max(ans[u],(*p).second);
	//for (auto p:S[to]) if(d<p.first) ans[u]=std::max(ans[u],p.second);
	for (int v:ch[u]){
		if(v==f||vis[v])continue;
		dfs2(v,u,to,d+1,std::min(lim,dis[u]+d));
	}
}

void solve(int x) {
	rt = 0;
	dfsp(x);
	get_rt(x,0,size[x]);
	assert(rt);
	int u = rt;
	vis[u] = 1;
	for (int v:ch[u]) 
		if (!vis[v]) dfs1(v,u,1,u);
	vec[u].push_back(mp(inf,dis[u]));
	std::sort(vec[u].begin(),vec[u].end());
//	S[u].insert(mp(0,0));
	
	int pre = 0;
	for (int i = vec[u].size()-1;i>=0;i--) {
		auto p = vec[u][i];
		int x = p.first, y = std::max(pre,p.second);
	//	printf("%d %d\n",x,y);
		pre = std::max(pre,y);
		S[u].push_back(mp(x,y));
	} std::sort(S[u].begin(),S[u].end());
	for (int v:ch[u]) if (!vis[v]) dfs2(v,u,u,1,dis[u]);
	//for (int i = 1; i <= n; ++ i) printf("%d ",ans[i]); puts("");
	for (int v:ch[u])if(!vis[v])solve(v);
}

int read(){
	int x=0;char c=getchar();
	while(c<'0'||c>'9')c=getchar();
	while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x;
}

int main() {
//	freopen("in.txt","r",stdin);
	scanf("%d",&n);
	for (int i = 1; i < n; ++ i) {
		u=read();v=read();
		ch[u].push_back(v);
		ch[v].push_back(u);
	} scanf("%d",&k);
	std::memset(dis,63,sizeof(dis));
	for (int i = 1; i <= k; ++ i) {
		a[i]=read();
		dis[a[i]] = 0;
		q.push(a[i]);
	} while (!q.empty()) {
		int u = q.front(); q.pop();
		for (int v:ch[u]) {
			if (dis[v] > dis[u] + 1) {
				dis[v] = dis[u] + 1;
				q.push(v);
			}
		}
	} for (int i =1;i<=n;++i)ans[i] = dis[i];//printf("%d ",dis[i]);puts(""); 
	solve(1);
	for (int i = 1; i <= n; ++ i) printf("%d ",ans[i]);
	return 0;
}