from sys import stdin n, m, *indata = map(int, stdin.read().split()) offset = 0 g = [[] for i in range(n+1)] for i in range(n-1): s, t = indata[offset + 2*i],indata[offset + 2*i+1] g[s].append((t,i)) g[t].append((s,i)) offset += (n-1)*2 d = [False for i in range(n+1)] for i in range(m): d[indata[offset + i]] = True que = [(1,0)] dp = [-1 for i in range(n+1)] dpdist = [-1 for i in range(n+1)] check = [0 for i in range(n+1)] while que: now, inout = que.pop() if inout == 0: check[now] = 1 que.append((now,1)) for i, ind in g[now]: if check[i] == 0: que.append((i,0)) else: kari = -1 distmax = -1 check[now] = 2 for i, ind in g[now]: if check[i] == 2: if dp[i] != -1: kari += dp[i] + 2 distmax = max(distmax,dpdist[i]) if kari != -1: kari += 1 distmax += 1 else: if d[now]: kari = 0 distmax = max(distmax,0) dp[now] = kari dpdist[now] = distmax dp2 = [-1 for i in range(n+1)] dpdist2 = [-1 for i in range(n+1)] que = [(1,-1)] check = [False for i in range(n+1)] while que: now, come = que.pop() check[now] = True ruiseki = [0] ruisekidist = [-1] for i, ind in g[now]: kari = ruiseki[-1] distmax = ruisekidist[-1] if ind != come: if dp[i] != -1: kari = kari + dp[i] + 2 distmax = max(distmax,dpdist[i]) else: if dp2[ind] != -1: kari = kari + dp2[ind] + 2 distmax = max(distmax,dpdist2[ind]) ruiseki.append(kari) ruisekidist.append(distmax) ruiseki2 = [0] ruisekidist2 = [-1] for i, ind in reversed(g[now]): kari = ruiseki2[-1] distmax = ruisekidist2[-1] if ind != come: if dp[i] != -1: kari = kari + dp[i] + 2 distmax = max(distmax,dpdist[i]) else: if dp2[ind] != -1: kari = kari + dp2[ind] + 2 distmax = max(distmax,dpdist2[ind]) ruiseki2.append(kari) ruisekidist2.append(distmax) dp[now] = ruiseki[-1] dpdist[now] = ruisekidist[-1] + 1 val = 0 for i, ind in g[now]: kari = ruiseki[val] + ruiseki2[-2-val] distmax = max(ruisekidist[val], ruisekidist2[-2-val]) dp2[ind] = kari dpdist2[ind] = distmax + 1 val += 1 for i, ind in g[now]: if not check[i]: que.append((i, ind)) for i in range(1,n+1): ans = dp[i] - dpdist[i] print("{}".format(ans))