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 int long long
const int maxn=2e5+100;
vector<int> g[maxn],d[maxn],ans[maxn];
int sz[maxn],dis[maxn],par[maxn];
bool vis[maxn];
int find(int s,int p=-1)
{
    sz[s]=1;
    for(auto it:g[s])
    {
        if(it!=p and !vis[it])
        sz[s]+=find(it,s);
    }
    return sz[s];
}
int find(int s,int p,int val)
{
    int res=-1;
    bool f=1;
    for(auto it:g[s])
    {
        if(it!=p and !vis[it])
        f&=sz[it]*2<=val;
        else if(it==p and !vis[it])
        f&=(val-sz[s])*2<=val;
    }
    if(f)
    res=s;
    for(auto it:g[s])
    if(it!=p and !vis[it])
    res=max(res,find(it,s,val));
    return res;
}
void check(int s,int p,int dd,int val)
{
    d[s].push_back(dd);
    for(auto it:g[s])
    if(it!=p and !vis[it])
    check(it,s,dd+1,val);
    dis[val]=max(dis[val],dd);
}
int check(int s)
{
    find(s);
    int c=find(s,s,sz[s]);
    vis[c]=1;
    for(auto it:g[c])
    if(!vis[it])
    par[check(it)]=c;
    vis[c]=0;
    check(c,c,0,c);
    return c;
}
signed main()
{
    int n;
    cin>>n;
    for(int i=1,x,y;i<n;i++)
    {
        cin>>x>>y;
        --x;
        --y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    check(0);
    for(int i=0;i<n;i++)
    ans[i].resize(dis[i]+1);
    int k;
    cin>>k;
    vector<int> dd(n,1e9);
    queue<int> q;
    for(int i=0;i<k;i++)
    {
        int x;
        cin>>x;
        --x;
        q.push(x);
        dd[x]=0;
    }
    while(!q.empty())
    {
        auto ss=q.front();
        q.pop();
        for(auto it:g[ss])
        if(dd[it]>dd[ss]+1)
        {
            q.push(it);
            dd[it]=dd[ss]+1;
        }
    }
    for(int i=0;i<n;i++)
    {
        if(dd[i]==0)
        continue;
        int cur=i;
        for(int j=0;j<d[i].size();j++)
        {
            int dtu=d[i][j];
            if(dtu>dd[i]-1)
            {
                cur=par[cur];
                continue;
            }
            dtu=dd[i]-1-dtu;
            if(dtu>=ans[cur].size())
            dtu=ans[cur].size()-1;
            ans[cur][dtu]=max(ans[cur][dtu],dd[i]);
            cur=par[cur];
        }
    }
    for(int i=0;i<n;i++)
    for(int j=dis[i];j>=1;j--)
    ans[i][j-1]=max(ans[i][j-1],ans[i][j]);
    for(int i=0;i<n;i++)
    {
        int res=0;
        int cur=i;
        for(int j=0;j<d[i].size();j++)
        {
            int dtu=d[i][j];
            res=max(res,ans[cur][dtu]);
            cur=par[cur];
        }
        if(dd[i]==0)
        res=0;
        cout<<res<<" \n"[i==n-1];
    }
    return 0;
}