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 ln                 '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 2e5;
bool on[nsz + 5], vis[nsz + 5];
int n, m, rt = 1, dis[nsz + 5], ans[nsz + 5];
int pr[nsz + 5], dep[nsz + 5], siz[nsz + 5], mxs[nsz + 5];

struct graph {
	int sz, hd[nsz + 5];
	
	struct edge {
		int nxt, to;
		
		edge() {}
		edge(int nxt, int to) {
			this->nxt = nxt, this->to = to;
		}
	} e[2 * nsz + 5];
	
	inline edge& operator [] (int id) { return e[id]; }
	
	void inline link(int u, int v) {
		e[++sz] = edge(hd[u], v), hd[u] = sz;
		e[++sz] = edge(hd[v], u), hd[v] = sz;
	}
};
graph g;

struct fenwick_tree {
	int t, tr[nsz + 5], tm[nsz + 5];
	
	void inline clear() { ++t; }
	
	void inline chg(int u) {
		if (tm[u] != t) tm[u] = t, tr[u] = 0;
	}
	
	void inline upd(int u, int w) {
		for (++u; u > 0; u -= u & -u) chg(u), tr[u] = max(tr[u], w);
	}
	
	int inline qry(int u) {
		int res = 0;
		for (++u; u <= n + 1; u += u & -u) chg(u), res = max(res, tr[u]);
		return res;
	}
};
fenwick_tree tr;

void inline bfs() {
	static int q[nsz + 5];
	int ql = 0, qr = 0;
	cont (u, n) dis[u] = n;
	cont (u, n) if (on[u]) dis[u] = 0, q[qr++] = u;
	for (; ql != qr;) {
		int u = q[ql++];
		for (int i = g.hd[u]; i; i = g[i].nxt) {
			int v = g[i].to;
			if (dis[v] > dis[u] + 1) dis[v] = dis[u] + 1, q[qr++] = v;
		}
	}
}

void dfs1(vector<int> &nd, int u, int p = -1) {
	siz[u] = mxs[u] = 1;
	nd.push_back(u);
	for (int i = g.hd[u]; i; i = g[i].nxt) {
		int v = g[i].to;
		if (v == p || vis[v]) continue;
		dfs1(nd, v, u);
		siz[u] += siz[v];
		mxs[u] = max(mxs[u], siz[v]);
	}
}

void dfs2(int u, int p = -1) {
	for (int i = g.hd[u]; i; i = g[i].nxt) {
		int v = g[i].to;
		if (v == p || vis[v]) continue;
		dep[v] = dep[u] + 1;
		dfs2(v, u);
	}
}

int inline find_rt(vector<int> &nd, int u) {
	dfs1(nd, u);
	int sz = siz[u];
	loop (i, nd.size()) {
		int u = nd[i], cur = max(mxs[u], sz - siz[u]);
		if (cur * 2 <= sz) return u;
	}
	return u;
}

void inline calc(vector<int> &nd, int u) {
	dep[u] = 0, dfs2(u);
	loop (i, nd.size()) {
		int u = nd[i], k = dis[u] - dep[u] - 1;
		if (k >= 0) tr.upd(k, dis[u]);
	}
	loop (i, nd.size()) {
		int u = nd[i], k = dep[u];
		ans[u] = max(ans[u], tr.qry(k));
	}
	tr.clear();
}

void solve(int u = rt) {
	vector<int> nd;
	u = find_rt(nd, u);
	calc(nd, u);
	vis[u] = 1;
	for (int i = g.hd[u]; i; i = g[i].nxt) {
		int v = g[i].to;
		if (!vis[v]) solve(v);
	}
}

int main() {
	scanf("%d", &n);
	cont (i, n - 1) {
		int u, v;
		scanf("%d%d", &u, &v);
		g.link(u, v);
	}
	scanf("%d", &m);
	cont (i, m) {
		int u;
		scanf("%d", &u);
		on[u] = 1;
	}
	bfs();
	solve();
	cont (u, n) printf("%d%c", ans[u], "\n "[u < n]);
}