#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]);
}