#include <cstdio>
#include <cstring>
#include <climits>
#include <new>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
const int MAX_N = 300000;
int n, m;
struct Tag {
int x;
bool del;
Tag(bool del, int x) : x(x), del(del) {}
};
struct Node;
struct Edge;
struct Chain;
struct Node {
Edge *e;
Node *fa, *maxc;
Chain *chain;
int size, dep, dfn, id, w, x, ans;
bool vis;
std::vector<Tag> forwTag, bacwTag;
} N[MAX_N];
struct Edge {
Node *fr, *to;
Edge *ne;
Edge() {}
Edge(Node *fr, Node *to) : fr(fr), to(to), ne(fr->e) {}
} _pool[MAX_N * 2], *_end;
inline void addEdge(int fr, int to) {
N[fr].e = new (_end++) Edge(&N[fr], &N[to]);
N[to].e = new (_end++) Edge(&N[to], &N[fr]);
}
struct Chain {
Node *top, *bot;
std::vector<Node *> nodes;
int len;
} chains[MAX_N];
int chainCnt = 0;
template<typename T>
struct Stack {
T s[MAX_N];
int tot;
Stack() : tot(0) {}
void push(T val) {
s[tot++] = val;
}
void pop() {
tot--;
}
bool empty() {
return tot == 0;
}
T top() {
return s[tot - 1];
}
};
Stack<Node *> s;
inline void split() {
N[1].dep = 1;
s.push(&N[1]);
while (!s.empty()) {
Node *v = s.top();
if (!v->vis) {
v->vis = true;
v->size = 1;
for (Edge *e = v->e; e; e = e->ne) {
if (e->to != v->fa) {
e->to->fa = v;
e->to->dep = v->dep + 1;
s.push(e->to);
}
}
} else {
for (Edge *e = v->e; e; e = e->ne) {
if (e->to->fa == v) {
v->size += e->to->size;
if (!v->maxc || e->to->size > v->maxc->size) v->maxc = e->to;
}
}
s.pop();
}
}
for (int i = 1; i <= n; i++) N[i].vis = false;
s.push(&N[1]);
N[1].dep = 1;
while (!s.empty()) {
Node *v = s.top();
if (!v->vis) {
v->vis = true;
if (!v->fa || v != v->fa->maxc) {
v->chain = &chains[chainCnt++];
v->chain->top = v;
v->id = 0;
} else {
v->chain = v->fa->chain;
v->id = v->fa->id + 1;
}
v->chain->nodes.push_back(v);
v->chain->bot = v;
for (Edge *e = v->e; e; e = e->ne) {
if (e->to->fa == v) s.push(e->to);
}
} else {
s.pop();
}
}
for (int i = 0; i < chainCnt; i++) chains[i].len = chains[i].nodes.size();
}
inline Node *lca(Node *u, Node *v) {
while (u->chain != v->chain) {
if (u->chain->top->dep < v->chain->top->dep) std::swap(u, v);
u = u->chain->top->fa;
}
if (u->dep > v->dep) return v;
else return u;
}
inline int dist(Node *u, Node *v, Node *p) {
return u->dep + v->dep - p->dep * 2;
}
inline void addTag(bool forw, Chain *chain, int s, int t, int x) {
if (forw) {
if (s > t) return;
chain->nodes[s]->forwTag.push_back(Tag(false, x));
chain->nodes[t]->forwTag.push_back(Tag(true, x));
} else {
if (s < t) return;
chain->nodes[s]->bacwTag.push_back(Tag(false, x));
chain->nodes[t]->bacwTag.push_back(Tag(true, x));
}
}
inline void play(Node *s, Node *t) {
if (s == t) {
if (s->w == 0) s->ans++;
return;
}
Node *p = lca(s, t), *u = s, *v = t;
if (dist(s, p, p) == p->w) p->ans++;
if (s != p) {
while (u->chain != p->chain) {
addTag(false, u->chain, u->id, 0, s->dep - u->dep + u->id);
u = u->chain->top->fa;
}
addTag(false, u->chain, u->id, p->id + 1, s->dep - u->dep + u->id);
}
if (t != p) {
while (v->chain != p->chain) {
addTag(true, v->chain, 0, v->id, (s->dep - p->dep) + (v->chain->top->dep - p->dep));
v = v->chain->top->fa;
}
addTag(true, v->chain, p->id + 1, v->id, (s->dep - p->dep) + (v->chain->top->dep - p->dep));
}
}
int _cnt[MAX_N * 4 + 1], *cnt = _cnt + MAX_N * 2;
inline void solve() {
for (int i = 0; i < chainCnt; i++) {
Chain &chain = chains[i];
for (int j = 0; j < chain.len; j++) {
for (std::vector<Tag>::const_iterator it = chain.nodes[j]->forwTag.begin(); it != chain.nodes[j]->forwTag.end(); it++) {
if (!it->del) cnt[it->x]++;
}
chain.nodes[j]->ans += cnt[chain.nodes[j]->w - j];
for (std::vector<Tag>::const_iterator it = chain.nodes[j]->forwTag.begin(); it != chain.nodes[j]->forwTag.end(); it++) {
if (it->del) cnt[it->x]--;
}
}
for (int j = chain.len - 1; j >= 0; j--) {
for (std::vector<Tag>::const_iterator it = chain.nodes[j]->bacwTag.begin(); it != chain.nodes[j]->bacwTag.end(); it++) {
if (!it->del) cnt[it->x]++;
}
chain.nodes[j]->ans += cnt[chain.nodes[j]->w + j];
for (std::vector<Tag>::const_iterator it = chain.nodes[j]->bacwTag.begin(); it != chain.nodes[j]->bacwTag.end(); it++) {
if (it->del) cnt[it->x]--;
}
}
}
}
int main() {
freopen("running.in", "r", stdin);
freopen("running.out", "w", stdout);
_end = _pool;
scanf("%d %d", &n, &m);
for (int i = 1; i < n; i++) {
int u, v;
scanf("%d %d", &u, &v);
addEdge(u, v);
}
split();
for (int i = 1; i <= n; i++) scanf("%d", &N[i].w);
for (int i = 1; i <= m; i++) {
int u, v;
scanf("%d %d", &u, &v);
play(&N[u], &N[v]);
}
solve();
for (int i = 1; i <= n; i++) printf("%d%c", N[i].ans, i == n ? '\n' : ' ');
return 0;
}