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>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define mii map<int, int>
#define vint vector<int>
#define pb push_back
#define mk make_pair
#define dbl double
const int inf = 0x3f3f3f3f;
const ll mod = 1000000007;
const ll linf = 0x3f3f3f3f3f3f3f3f;
#define deb(k) cerr << #k << ": " << k << "\n";
#define fastcin cin.tie(0)->sync_with_stdio(0);
#define st first
#define nd second
#define MAXN 200100
#define MAXLG 20
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int N;
vector<int> adj[MAXN];
int sz[MAXN];
int cpar[MAXN];
bool vis[MAXN];
int d[MAXN];
vector<int> val[MAXN];
vector<int> tree[MAXN];
int n;

void dfs( int n, int p = -1 ) {
	sz[n] = 1;
	for( int v : adj[n] ) if( v != p && !vis[v] ) dfs( v, n ), sz[n] += sz[v];
}

void dfs2(int n, int centroid,  int p = -1 ){
	tree[centroid].pb(n);
	for( int v : adj[n] ){
		if(v != p && !vis[v]){
			dfs2(v, centroid, n);
		}
	}
}

int centroid( int n ) {
	dfs( n );
	int num = sz[n];
	int p = -1;
	do {
		int nxt = -1;
		for( int v : adj[n] ) if( v != p && !vis[v] )
			if( 2 * sz[v] > num ) nxt = v;
		p = n, n = nxt;
	} while( ~n );
	dfs2(p, p);
	return p;
}

void decomp( int n = 0, int p = -1 ) {
	int c = centroid( n );
	vis[c] = true;
	cpar[c] = p;
	for( int v : adj[c] ) if ( !vis[v] ) decomp( v, c );
}

vector<int>ans;
vector<int>chip;
vector<int>ord;
vector<int>depth;
vector<int>dist[MAXN];
vector<bool>cur;

bool cmp(int x, int y){
	return tree[x].size() < tree[y].size();
}

void dfs3(int x, int p = -1){
	for(auto v : adj[x]){
		if(v == p || !cur[v]) continue;
		depth[v] = depth[x] + 1;
		dfs3(v, x);
	}
}

void bfs(){
	queue<int>q;
	memset(d, 63, sizeof d);
	for(auto v : chip) q.push(v), d[v] = 0;
	while(!q.empty()){
		int u = q.front();
		q.pop();
		for(auto v : adj[u]){
			if(d[v] == inf){
				d[v] = d[u] + 1;
				q.push(v);
			}
		}
	}
}

bool f(int v, int x){
	int i = 0, u = v;
	while(u!=-1){
		if(x - dist[v][i] >= 0 && val[u][min((int)val[u].size() - 1, x - dist[v][i])] > x)
			return true;

		u = cpar[u];
		i++;
	}
	return false;
}

void solve(){
	cin>>n;
	ord.resize(n);
	ans.resize(n);
	for(int i=0;i<n;i++) ans[i] = inf, ord[i] = i;
	for(int i=1;i<n;i++){
		int a,b;
		cin>>a>>b;
		a--, b--;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	int k;
	cin>>k;
	chip.resize(k);
	for(int i=0;i<k;i++) cin>>chip[i], chip[i]--;
	bfs();
	decomp();
	depth.resize(n);
	cur.resize(n);
	sort(ord.begin(), ord.end(), cmp);
	for(auto i : ord){
		for(auto v : tree[i]) cur[v] = 1;
		depth[i] = 0;
		dfs3(i);
		int mx = 0;
		for(auto v : tree[i]) mx = max(mx, depth[v]);
		val[i].resize(mx+1);
		for(auto v : tree[i]) val[i][depth[v]] = max(val[i][depth[v]], d[v]);
		for(int j=0;j<mx;j++) val[i][j+1] = max(val[i][j+1], val[i][j]);
		for(auto v : tree[i]) cur[v] = 0;
		for(auto v : tree[i]) dist[v].pb(depth[v]);
	}


	for(int i=0;i<n;i++){
		int lo = 0, hi = n-1;
		while(lo <= hi){
			int mid = (lo+hi)/2;
			if(f(i, mid)) lo = mid+1;
			else hi = mid-1;
		}
		cout<<lo<<" ";
	}
	cout<<"\n";

	// Have you read the problem again?
	// Maybe you understood the wrong problem
}

int main(){
	fastcin;
	solve();
	return 0;
}