#include <bits/stdc++.h>
#define N 200011

using namespace std;

#define pb push_back

int n, H[N];
vector<int> adj[N];

/* ----- Centroid Decom ----- */
int sub[N];
int par[N];
int used[N];
int max_dist[N];
vector<int> treeAdj[N];
vector<int> dist[N];
vector<int> val[N];

int dfs(int v, int p) {

	sub[v] = 1;
	for(int u : adj[v])
		if(u != p and !used[u])
			sub[v] += dfs(u, v);
	return sub[v];

}

int getCentroid(int v, int p, int k) {
	for(int u : adj[v])
		if(u != p and !used[p] and sub[u] > k/2)
			return getCentroid(u, v, k);
	return v;
}

int findCentroid(int v, int p, int k)
{
    int ans = -1;
    bool good = true;
    for(auto u : adj[v])
        if(u != p && !used[u])
            good &= sub[u] * 2 <= k;
        else if(u == p && !used[u])
            good &= (k - sub[v]) * 2 <= k;
    if(good)
        ans = v;
    for(auto u : adj[v])
        if(u != p && !used[u])
            ans = max(ans, findCentroid(u, v, k));
    return ans;
}

void calcDist(int v, int p, int d, int s) {

	dist[v].pb(d);
	for(int u : adj[v])
		if(u != p and !used[u])
			calcDist(u, v, d + 1, s);
	max_dist[s] = max(max_dist[s], d);

}

int build(int v, int p) {

	int k = dfs(v, p);
	int c = findCentroid(v, p, k);
	par[c] = p;
	used[c] = true;

	for(int u : adj[c]) {
		if(used[u]) continue;
		int uu = build(u, c);
		treeAdj[c].pb(uu);
	}

	used[c] = false;
	calcDist(c, c, 0, c);
	return c;

}

int buildCentroidDecom() {

	int res = build(0, -1);
	for(int i=0; i<n; i++)
		val[i].resize(max_dist[i]+1, 0);
	return res;

}

signed main() {

	scanf("%d", &n);
	for(int i=1; i<n; i++) {

		int u, v;
		scanf("%d %d", &u, &v);
		u--; v--;

		adj[u].pb(v);
		adj[v].pb(u);

	}

	int k;
	queue<int> bfs;
	memset(H, -1, sizeof H);

	scanf("%d", &k);
	while(k--) {
		int x;
		scanf("%d", &x);
		H[--x] = 0;
		bfs.push(x);
	}

	while(!bfs.empty()) {

		int v = bfs.front();
		bfs.pop();
		for(int u : adj[v]) {

			if(H[u] != -1) continue;
			H[u] = H[v] + 1;
			bfs.push(u);

		}

	}

	int root = buildCentroidDecom();

	for(int i=0; i<n; i++) {

		if(H[i] == 0) continue;

		int c = i;
		int h = H[i] - 1;
		int k = 0;
		while(c != -1) {

			int d = dist[i][k];
			int dd = h - d;
			dd = min(max_dist[c], dd);
			if(dd >= 0) val[c][dd] = max(val[c][dd], H[i]);
			c = par[c];
			k++;

		}

	}

	for(int i=0; i<n; i++) {

		int k = max_dist[i] + 1;
		for(int j=k-2; j>=0; j--)
			val[i][j] = max(val[i][j], val[i][j+1]);

	}

	for(int i=0; i<n; i++) {

		if(H[i] == 0) printf("0 ");
		else {

			int res = H[i];
			int c = i;
			int k = 0;

			while(c != -1) {

				int d = dist[i][k];
				res = max(res, val[c][d]);
				c = par[c];
				k++;

			}

			printf("%d ", res);

		}

	}

	return 0;
}
