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