#include <iostream>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <ctime>
#pragma comment(linker, "/STACK:256000000")

using namespace std;

const int maxN = 101000;

pair<int, int> t[4 * maxN];
int add[4 * maxN];

pair<int, int> merge(pair<int, int> a, pair<int, int> b) {
  if (a.first < b.first) {
    return a;
  }
  if (a.first > b.first) {
    return b;
  }
  return make_pair(a.first, a.second + b.second);
}

void build(int v, int cl, int cr) {
  if (cl == cr) {
    t[v] = make_pair(0, 1);
    return;
  }
  int mid = (cl + cr) / 2;
  build(2 * v, cl, mid);
  build(2 * v + 1, mid + 1, cr);
  t[v] = merge(t[2 * v], t[2 * v + 1]);
}

void push(int v, int cl, int cr) {
  int mid = (cl + cr) / 2;
  add[2 * v] += add[v];
  add[2 * v + 1] += add[v];
  t[2 * v].first += add[v];
  t[2 * v + 1].first += add[v];
  add[v] = 0;
}

void update(int v, int cl, int cr, int tl, int tr, int value) {
  if (cl == tl && cr == tr) {
    add[v] += value;
    t[v].first += value;
    return;
  }
  int mid = (cl + cr) / 2;
  push(v, cl, cr);
  if (tl > mid) {
    update(2 * v + 1, mid + 1, cr, tl, tr, value);
  } else
  if (tr <= mid) {
    update(2 * v, cl, mid, tl, tr, value);
  } else {
    update(2 * v, cl, mid, tl, mid, value);
    update(2 * v + 1, mid + 1, cr, mid + 1, tr, value);
  }
  t[v] = merge(t[2 * v], t[2 * v + 1]);
}

pair<int, int> get(int v, int cl, int cr, int tl, int tr) {
  if (cl == tl && cr == tr) {
    return t[v];
  }
  int mid = (cl + cr) / 2;
  push(v, cl, cr);
  if (tl > mid) return get(2 * v + 1, mid + 1, cr, tl, tr);
  if (tr <= mid) return get(2 * v, cl, mid, tl, tr);
  return merge(get(2 * v, cl, mid, tl, mid), get(2 * v + 1, mid + 1, cr, mid + 1, tr));
}

vector <int> g[maxN];
vector <int> opers[maxN];
vector <int> cols[maxN];
int n, m;

vector <int> order;
int inv[maxN];
int l[maxN], r[maxN];

void dfs(int v, int p = -1) {
  order.push_back(v);
  l[v] = v;
  for (int i = 0; i < g[v].size(); ++i) {
    if (g[v][i] != p) {
      dfs(g[v][i], v);
    }
  }
  r[v] = v;
  for (int i = 0; i < g[v].size(); ++i) {
    if (g[v][i] != p) {
      r[v] = r[g[v][i]];
    }
  }
}

int res[maxN];

void dfs2(int v, int p = -1) {
  for (int i = 0; i < opers[v].size(); ++i) {
    int ccol = opers[v][i];
    for (int j = 0; j < cols[ccol].size(); ++j) {
      int t = cols[ccol][j];
      update(1, 0, n - 1, l[t], r[t], +1);
    }
  }
  pair<int, int> cres = get(1, 0, n - 1, 0, n - 1);
  res[v] = cres.second;
  if (cres.first != 0) {
    res[v] = 0;
  }

  for (int i = 0; i < g[v].size(); ++i) {
    if (g[v][i] != p) {
      dfs2(g[v][i], v);
    }
  }

  for (int i = 0; i < opers[v].size(); ++i) {
    int ccol = opers[v][i];
    for (int j = 0; j < cols[ccol].size(); ++j) {
      int t = cols[ccol][j];
      update(1, 0, n - 1, l[t], r[t], -1);
    }
  }
}

int main() {
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  scanf("%d%d", &n, &m);
  build(1, 0, n - 1);
  for (int i = 1; i < n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }

  dfs(1);
  for (int i = 0; i < order.size(); ++i) {
    inv[order[i]] = i;
  }
  for (int i = 1; i <= n; ++i) {
    l[i] = inv[l[i]];
    r[i] = inv[r[i]];
  }

  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    cols[i].push_back(x);
    cols[i].push_back(y);
    opers[x].push_back(i);
    opers[y].push_back(i);
  }

  dfs2(1);
  for (int i = 1; i <= n; ++i) {
    int val = n - res[i];
    if (val > 0) --val;
    printf("%d ", val);
  }
  printf("\n");

  return 0;
}


#include <iostream>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <ctime>
#pragma comment(linker, "/STACK:256000000")

using namespace std;

const int maxN = 101000;

pair<int, int> t[4 * maxN];
int add[4 * maxN];

pair<int, int> merge(pair<int, int> a, pair<int, int> b) {
  if (a.first < b.first) {
    return a;
  }
  if (a.first > b.first) {
    return b;
  }
  return make_pair(a.first, a.second + b.second);
}

void build(int v, int cl, int cr) {
  if (cl == cr) {
    t[v] = make_pair(0, 1);
    return;
  }
  int mid = (cl + cr) / 2;
  build(2 * v, cl, mid);
  build(2 * v + 1, mid + 1, cr);
  t[v] = merge(t[2 * v], t[2 * v + 1]);
}

void push(int v, int cl, int cr) {
  int mid = (cl + cr) / 2;
  add[2 * v] += add[v];
  add[2 * v + 1] += add[v];
  t[2 * v].first += add[v];
  t[2 * v + 1].first += add[v];
  add[v] = 0;
}

void update(int v, int cl, int cr, int tl, int tr, int value) {
  if (cl == tl && cr == tr) {
    add[v] += value;
    t[v].first += value;
    return;
  }
  int mid = (cl + cr) / 2;
  push(v, cl, cr);
  if (tl > mid) {
    update(2 * v + 1, mid + 1, cr, tl, tr, value);
  } else
  if (tr <= mid) {
    update(2 * v, cl, mid, tl, tr, value);
  } else {
    update(2 * v, cl, mid, tl, mid, value);
    update(2 * v + 1, mid + 1, cr, mid + 1, tr, value);
  }
  t[v] = merge(t[2 * v], t[2 * v + 1]);
}

pair<int, int> get(int v, int cl, int cr, int tl, int tr) {
  if (cl == tl && cr == tr) {
    return t[v];
  }
  int mid = (cl + cr) / 2;
  push(v, cl, cr);
  if (tl > mid) return get(2 * v + 1, mid + 1, cr, tl, tr);
  if (tr <= mid) return get(2 * v, cl, mid, tl, tr);
  return merge(get(2 * v, cl, mid, tl, mid), get(2 * v + 1, mid + 1, cr, mid + 1, tr));
}

vector <int> g[maxN];
vector <int> opers[maxN];
vector <int> cols[maxN];
int n, m;

vector <int> order;
int inv[maxN];
int l[maxN], r[maxN];

void dfs(int v, int p = -1) {
  order.push_back(v);
  l[v] = v;
  for (int i = 0; i < g[v].size(); ++i) {
    if (g[v][i] != p) {
      dfs(g[v][i], v);
    }
  }
  r[v] = v;
  for (int i = 0; i < g[v].size(); ++i) {
    if (g[v][i] != p) {
      r[v] = r[g[v][i]];
    }
  }
}

int res[maxN];

void dfs2(int v, int p = -1) {
  for (int i = 0; i < opers[v].size(); ++i) {
    int ccol = opers[v][i];
    for (int j = 0; j < cols[ccol].size(); ++j) {
      int t = cols[ccol][j];
      update(1, 0, n - 1, l[t], r[t], +1);
    }
  }
  pair<int, int> cres = get(1, 0, n - 1, 0, n - 1);
  res[v] = cres.second;

  for (int i = 0; i < g[v].size(); ++i) {
    if (g[v][i] != p) {
      dfs2(g[v][i], v);
    }
  }

  for (int i = 0; i < opers[v].size(); ++i) {
    int ccol = opers[v][i];
    for (int j = 0; j < cols[ccol].size(); ++j) {
      int t = cols[ccol][j];
      update(1, 0, n - 1, l[t], r[t], -1);
    }
  }
}

int main() {
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  scanf("%d%d", &n, &m);
  build(1, 0, n - 1);
  for (int i = 1; i < n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }

  dfs(1);
  for (int i = 0; i < order.size(); ++i) {
    inv[order[i]] = i;
  }
  for (int i = 1; i <= n; ++i) {
    l[i] = inv[l[i]];
    r[i] = inv[r[i]];
  }

  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    cols[i].push_back(x);
    cols[i].push_back(y);
    opers[x].push_back(i);
    opers[y].push_back(i);
  }

  dfs2(1);
  for (int i = 1; i <= n; ++i) {
    int val = n - res[i];
    if (val > 0) --val;
    printf("%d ", val);
  }
  printf("\n");

  return 0;
}


/* practice with Dukkha */
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>

#define N	100000
#define N_	(1 << 17)	/* N_ = pow2(ceil(log2(N))) */
#define M	100000

void srand_() {
	struct timeval tv;

	gettimeofday(&tv, NULL);
	srand(tv.tv_sec ^ tv.tv_usec);
}

int rand_(int n) {
	return (rand() * 76543LL + rand()) % n;
}

int next[1 + (N - 1) * 2], jj[1 + (N - 1) * 2];
int ao[N], ll[N], rr[N], ii[N];

int link(int l, int j) {
	static int _ = 1;

	next[_] = l;
	jj[_] = j;
	return _++;
}

void dfs(int p, int i) {
	static int time;
	int l;

	ii[ll[i] = time++] = i;
	for (l = ao[i]; l; l = next[l]) {
		int j = jj[l];

		if (j != p)
			dfs(i, j);
	}
	rr[i] = time;
}

struct V {
	int l, r, y, pm;
} vv[M * 8];

int compare(const void *a, const void *b) {
	struct V *u = (struct V *) a;
	struct V *v = (struct V *) b;

	return u->y - v->y;
}

void sort(struct V *vv, int n) {
	int i;

	for (i = 0; i < n; i++) {
		int j = rand_(i + 1);
		struct V tmp;

		tmp = vv[i], vv[i] = vv[j], vv[j] = tmp;
	}
	qsort(vv, n, sizeof *vv, compare);
}

int tr[N_ * 2], kk[N_ * 2], sz[N_ * 2], n_;

void build(int n) {
	int i;

	n_ = 1;
	while (n_ < n)
		n_ <<= 1;
	for (i = 0; i < n; i++)
		sz[n_ + i] = 1;
	for (i = n_ - 1; i >= 0; i--)
		sz[i] = sz[i << 1] + sz[i << 1 | 1];
}

void pul(int i) {
	if (kk[i])
		tr[i] = sz[i];
	else
		tr[i] = i < n_ ? tr[i << 1] + tr[i << 1 | 1] : 0;
}

void put(int i, int x) {
	kk[i] += x;
	pul(i);
}

void pull(int i) {
	while (i > 1)
		pul(i >>= 1);
}

void update(int l, int r, int x) {
	int l_ = l += n_, r_ = r += n_;

	for ( ; l <= r; l >>= 1, r >>= 1) {
		if ((l & 1) == 1)
			put(l++, x);
		if ((r & 1) == 0)
			put(r--, x);
	}
	pull(l_), pull(r_);
}

int main() {
	static int ans[N];
	int n, m, h, i, j, y;

	srand_();
	scanf("%d%d", &n, &m);
	for (h = 0; h < n - 1; h++) {
		scanf("%d%d", &i, &j), i--, j--;
		ao[i] = link(ao[i], j);
		ao[j] = link(ao[j], i);
	}
	dfs(-1, 0);
	for (h = 0; h < m; h++) {
		struct V *v;
		int li, ri, lj, rj;

		scanf("%d%d", &i, &j), i--, j--;
		li = ll[i], ri = rr[i], lj = ll[j], rj = rr[j];
		/* [li, ri) x [li, ri) */
		v = &vv[h * 8 + 0];
		v->l = li, v->r = ri, v->y = li, v->pm = 1;
		v = &vv[h * 8 + 1];
		v->l = li, v->r = ri, v->y = ri, v->pm = -1;
		/* [li, ri) x [lj, rj) */
		v = &vv[h * 8 + 2];
		v->l = li, v->r = ri, v->y = lj, v->pm = 1;
		v = &vv[h * 8 + 3];
		v->l = li, v->r = ri, v->y = rj, v->pm = -1;
		/* [lj, rj) x [li, ri) */
		v = &vv[h * 8 + 4];
		v->l = lj, v->r = rj, v->y = li, v->pm = 1;
		v = &vv[h * 8 + 5];
		v->l = lj, v->r = rj, v->y = ri, v->pm = -1;
		/* [lj, rj) x [lj, rj) */
		v = &vv[h * 8 + 6];
		v->l = lj, v->r = rj, v->y = lj, v->pm = 1;
		v = &vv[h * 8 + 7];
		v->l = lj, v->r = rj, v->y = rj, v->pm = -1;
	}
	sort(vv, m * 8);
	build(n);
	for (y = 0, h = 0; y < n; y++) {
		struct V *v;

		while (h < m * 8 && (v = &vv[h])->y <= y) {
			update(v->l, v->r - 1, v->pm);
			h++;
		}
		ans[ii[y]] = tr[1] == 0 ? 0 : tr[1] - 1;
	}
	for (i = 0; i < n; i++)
		printf("%d ", ans[i]);
	printf("\n");
	return 0;
}


using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    SegTree Seg;
    List<int>[] G;
    int[] order;
    int[] start;
    int oc;
    bool[] us;
    List<int>[] Pa;
    int[] ans;
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.WriteLine(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        int N = int.Parse(str[0]);
        int Q = int.Parse(str[1]);
        G = new List<int>[N];
        for(int i=0;i<N;i++){
            G[i] = new List<int>();
        }
        for(int i=0;i<N-1;i++){
            str = Console.ReadLine().Split(' ');
            int v = int.Parse(str[0]) - 1;
            int u = int.Parse(str[1]) - 1;
            G[v].Add(u);
            G[u].Add(v);
        }
        order = new int[N];
        start = new int[N];
        oc = 0;
        us = new bool[N];
        eulertour(0);
        Pa = new List<int>[N];
        for(int i=0;i<N;i++){
            Pa[i] = new List<int>();
        }
        for(int i=0;i<Q;i++){
            str = Console.ReadLine().Split(' ');
            int v = int.Parse(str[0]) - 1;
            int u = int.Parse(str[1]) - 1;
            Pa[v].Add(u);
            Pa[u].Add(v);
        }
        ans = new int[N];
        Seg = new SegTree(N,this);
        for(int i=2*N-2;i>=0;i--){
            if(i >= Seg.segf){
                Seg.minc[i] = 1;
            }
            else{
                int sl = i*2+1;
                int sr = i*2+2;
                Seg.minc[i] = Seg.minc[sl] + Seg.minc[sr];
            }
        }
        us = new bool[N];
        dfs(0);
        for(int i=0;i<N;i++){
            int fa = ans[i] == N ? 0 : N - ans[i] - 1;
            sb.Append(fa + " ");
        }
    }
    void eulertour(int v){
        us[v] = true;
        start[v] = oc;
        for(int i=0;i<G[v].Count;i++){
            int t = G[v][i];
            if(!us[t]){
                eulertour(t);
            }
        }
        order[v] = oc;
        oc++;
    }
    void dfs(int v){
        us[v] = true;
        if(Pa[v].Count != 0){
            Seg.Add(start[v],order[v],1);
        }
        for(int i=0;i<Pa[v].Count;i++){
            int t = Pa[v][i];
            Seg.Add(start[t],order[t],1);
        }
        ans[v] = Seg.Get();
        for(int i=0;i<G[v].Count;i++){
            int t = G[v][i];
            if(!us[t]){
                dfs(t);
            }
        }
        if(Pa[v].Count != 0){
            Seg.Add(start[v],order[v],-1);
        }
        for(int i=0;i<Pa[v].Count;i++){
            int t = Pa[v][i];
            Seg.Add(start[t],order[t],-1);
        }
    }
}
struct SegTree{
    Solve Sol;
    public int[] minc;
    public int[] min;
    public int[] toc;
    //葉の最初の場所
    public int segf;
    //segfのbit
    public int segfb;
    //葉の深さの内浅い方
    public int depth;
    //浅い葉の内座標が最大のもの
    public int borderP;
    //はみ出すものの数
    public int border;
    public SegTree(int N,Solve So){
        Sol = So;
        minc = new int[2*N-1];
        min = new int[2*N-1];
        toc = new int[2*N-1];
        for(depth = 1;(1 << depth) <= N;depth++){
            ;
        }
        segf = N-1;
        borderP = (1 << depth) - 2;
        border = 2*N - borderP - 2;
        segfb = border/2;
    }
    public int ToBit(int p){
        if(p >= border){
            return segfb + p - border;
        }
        else{
            return p;
        }
    }
    //葉のある場所
    public int ToLeaf(int p){
        if(p >= border){
            return segf + p - border;
        }
        else{
            return borderP + p + 1;
        }
    }
    //葉の示す頂点
    public int ToPoint(int leaf){
        if(leaf > borderP){
            return leaf - borderP - 1;
        }
        else{
            return leaf - segf + border;
        }
    }
    public int Get(){
        return min[0] == 0 ? minc[0] : 0;
    }
    void Act(int v,int C){
        min[v] += C;
        toc[v] += C;
    }
    void Com(int v){
        if(v < segf && toc[v] != 0){
            Act(v*2+1,toc[v]);
            Act(v*2+2,toc[v]);
            toc[v] = 0;
        }
    }
    void Adjust(int v){
        if(v < segf){
            min[v] = Math.Min(min[v*2+1],min[v*2+2]);
            if(min[v*2+1] > min[v*2+2]){
                minc[v] = minc[v*2+2];
            }
            else if(min[v*2+1] < min[v*2+2]){
                minc[v] = minc[v*2+1];
            }
            else{
                minc[v] = minc[v*2+1]+minc[v*2+2];
            }
        }
    }
    //vの子の内bより大きいものに(bは子孫,bはToBitしたもの)
    void More(int b,int v,int depth,int C){
        Com(v);
        if((b & (1 << depth)) == 0){
            //右の子は全てbより大きい
            if(((b+1) % (1 << depth)) != 0){
                More(b,v*2+1,depth-1,C);
                Act(v*2+2,C);
            }
            else{
                Act(v*2+2,C);
            }
        }
        else{
            //左の子は全てb未満
            More(b,v*2+2,depth-1,C);
        }
        Adjust(v);
    }
    //vの子の内bより小さなものに(bは子孫,bはToBitしたもの)
    void Less(int b,int v,int depth,int C){
        Com(v);
        if((b & (1 << depth)) == 0){
            //右の子は全てbより大きい
            Less(b,v*2+1,depth-1,C);
        }
        else{
            //左の子は全てb未満
            if(b % (1 << depth) != 0){
                Act(v*2+1,C);
                Less(b,v*2+2,depth-1,C);
            }
            else{
                //右の子は全てb以上
                Act(v*2+1,C);
            }
        }
        Adjust(v);
    }
    void Section(int bl,int br,int v,int dl,int dr,int C){
        Com(v);
        if(v >= segf){
            //葉
            Act(v,C);
        }
        else{
            if((bl & (1 << dl)) == 0 && (br & (1 << dr)) == 0){
                //両方左
                Section(bl,br,v*2+1,dl-1,dr-1,C);
            }
            else if((bl & (1 << dl)) != 0 && (br & (1 << dr)) != 0){
                //両方右
                Section(bl,br,v*2+2,dl-1,dr-1,C);
            }
            else{
                //左と右に分かれた
                if(bl % (1 << dl) != 0){
                    More(bl-1,v*2+1,dl-1,C);
                }
                else{
                    //左は全て含まれる
                    Act(v*2+1,C);
                }
                if((br + 1) % (1 << dl) != 0){
                    Less(br+1,v*2+2,dr-1,C);
                }
                else{
                    //右は全て含まれる
                    Act(v*2+2,C);
                }
            }
        }
        Adjust(v);
    }
    public void Add(int l0,int r0,int C){
        int bl = ToBit(l0);
        int br = ToBit(r0);
        int dl = l0 >= border ? depth - 2 : depth - 1;
        int dr = r0 >= border ? depth - 2 : depth - 1;
        Section(bl,br,0,dl,dr,C);
    }
}


/*****************************************************************
 *                   BISMILLAHIR RAHMANIR RAHIM                  *
 *          Raihat Zaman Neloy                                   *
 *          JU-CSE-21                                            *
 *          raihatneloy                                          *
 *****************************************************************/

#include<algorithm>
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<deque>
#include<climits>
#include<complex>

#define S scanf
#define P printf

#define LL long long int
#define ULL unsigned long long int
#define D double

#define Max(a,b)    (a>b?a:b)
#define Min(a,b)    (a<b?a:b)
#define _Max(a,b,c) Max(a,Max(b,c))
#define _Min(a,b,c) Min(a,Min(b,c))
#define SQR(n)      (n*n)
#define PI          2.0*acos(0.0)

#define all(a) a.begin(),a.end()
#define X  first
#define Y  second
#define MP make_pair

#define NL         printf("\n");

#define open       freopen("input.txt","r",stdin)
#define close      freopen ("output.txt","w",stdout)
#define Case(a)    printf("Case %d:",a)
#define caseh(a)   printf("Case #%d: ",a)
#define S1(a)      scanf("%d",&a)
#define S2(a,b)    scanf("%d%d",&a,&b)
#define S3(a,b,c)  scanf("%d%d%d",&a,&b,&c)
#define SL1(a)     scanf("%lld",&a)
#define SL2(a,b)   scanf("%lld%lld",&a,&b)
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define CHR        getchar()
#define PB(x)      push_back(x)
#define pb         push_back
#define PP         pop_back()
#define PF(x)      push_front(x)
#define PPF(x)     pop_front()
#define PS(x)      push(x)
#define sz()       size()
#define UB         upper_bound
#define LB         lower_bound
#define mxe(a,n)   (*max_element(a,a+n))
#define mne(a,n)   (*min_element(a,a+n))
#define SUM(a,n)   (accumulate(a,a+n,0))
#define countbit(x) __builtin_popcount(x)
#define DBG(n)      P("Done %d\n",n);

#define DI(X) int (X);             scanf("%d", &X)
#define DII(X, Y) int X, Y;        scanf("%d%d", &X, &Y)
#define DIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)

#define DILL(X) LL (X); scanf("%lld", &X)

// LOOP
#define repv(i,a) for(int i=0;i<(int)a.size();i++)
#define revv(i,a) for(int i=((int)a.size())-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)

#define FS(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)
#define PR(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++) {  cout << *it << " "; } cout << endl;

#define MEM(a,val) memset(a,val,sizeof(a));
#define SET(a)     memset(a,-1,sizeof a)
#define CLR(a)     memset(a,0,sizeof a)

using namespace std;

template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> T in(){char ch;T n = 0;bool ng = false;while (1){ch = getchar();if (ch == '-'){ng = true;ch = getchar();break;}if (ch>='0' && ch<='9')     break;}while (1){n = n*10 + (ch - '0');ch = getchar();if (ch<'0' || ch>'9')   break;}return (ng?-n:n);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
template <typename T> T Bigmod(T b,T p,T m){ if(p==0) return 1; else if (!(p&1)) return SQR(Bigmod(b,p/2,m)) % m;else return ((b % m) * Bigmod(b,p-1,m)) % m;}
template <typename T> T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
template <typename T> T DIFF(T a,T b) { T d = a-b;if(d<0)return -d;else return d;}
template <typename T> T ABS(T a) {if(a<0)return -a;else return a;}
template <typename T> T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
template <typename T> T euclide(T a,T b,T &x,T &y) {if(a<0){T d=euclide(-a,b,x,y);x=-x;return d;}   if(b<0){T d=euclide(a,-b,x,y);y=-y;return d;}   if(b==0){x=1;y=0;return a;}else{T d=euclide(b,a%b,x,y);T t=x;x=y;y=t-(a/b)*y;return d;}}
template <typename T> void ia (T a[],int n){for (int i=0; i<n; i++) cin >> a[i];}
template <typename T> void pa (T a[],int n){for (int i=0; i<n-1; i++) cout << a[i] << " ";cout << a[n-1] << endl;}
template <typename T> LL isLeft(T a,T b,T c) { return (a.x-b.x)*(b.y-c.y)-(b.x-c.x)*(a.y-b.y); }

int    Set(int N,int pos){ return N=N | (1<<pos);}
int  Reset(int N,int pos){return N= N & ~(1<<pos);}
bool Check(int N,int pos){return (bool)(N & (1<<pos));}
template< class T, class X > inline T   togglebit(T a, X i) { T t=1;return (a^(t<<i)); }

int toInt(string s)  { int sm; stringstream ss(s); ss>>sm; return sm; }
int toLlint(string s) { long long int sm; stringstream ss(s); ss>>sm; return sm;}
int cdigittoint(char ch){return ch-'0';}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
bool isConst(char ch){if (isalpha(ch) && !isVowel(ch)) return true; return false;}

double DEG(double x) { return (180.0*x)/(PI);}
double RAD(double x) { return (x*(double)PI)/(180.0);}

#define VI  vector< int >
#define VII vector< VI >
#define VLL vector< LL >
#define PII pair< int , int >
#define PLL pair< LL , LL >
#define VPI vector< PII >

///         0123456789
#define MX  200007
#define MOD 1000000007
#define INF (1<<30)-1+(1<<30)
#define eps 1e-9

struct Node{
    int sum,lazy;
    Node *l,*r;

    Node(){
        sum = lazy = 0;
        l = r = NULL;
    }
};

VI adj[MX],query[MX];
int st[MX],ed[MX];
int node;
Node* Tree[MX];
Node Nodes[1000007];
int cnt;
int ans[MX];

void Dfs(int u,int p){
    st[u] = ++node;

    for (int i=0;i<adj[u].size();i++){
        int v = adj[u][i];

        if (v != p)     Dfs(v,u);
    }

    ed[u] = node;
}

Node* Propagate(Node *u,int l,int r){
    if (u == NULL)  u = &Nodes[++cnt];

    u->lazy = 1;
    u->sum = (r-l+1);
    u->l = u->r = NULL;
}

Node* Update(Node *idx,int l,int r,int s,int e){
    Node *u = &Nodes[++cnt];

    if (idx != NULL)        *u = *idx;

    if(s == l && e == r)    return Propagate(u,l,r);

    int mid = (l+r)>>1;

    if (u->lazy){
        u->l = Propagate(u->l,l,mid);
        u->r = Propagate(u->r,mid+1,r);
    }

    if (e <= mid)       u->l = Update(u->l,l,mid,s,e);
    else if (s > mid)   u->r = Update(u->r,mid+1,r,s,e);
    else{
        u->l = Update(u->l,l,mid,s,mid);
        u->r = Update(u->r,mid+1,r,mid+1,e);
    }

    u->sum = 0;

    if (u->l != NULL)       u->sum += u->l->sum;
    if (u->r != NULL)       u->sum += u->r->sum;

    return u;
}

void Bfs(int s,int n){
    Tree[0] = NULL;

    queue<int> q;

    q.PS(s);
    q.PS(0);

    while (!q.empty()){
        int u = q.front();q.pop();
        int p = q.front();q.pop();

        Tree[u] = Tree[p];

        for (int i=0;i<query[u].size();i+=2){
            int x = query[u][i];
            int y = query[u][i+1];

            Tree[u] = Update(Tree[u],1,n,x,y);
        }

        ans[u] = (Tree[u]==NULL?0:Tree[u]->sum-1);

        for (int i=0;i<adj[u].size();i++){
            int v = adj[u][i];

            if (v != p){
                q.PS(v);
                q.PS(u);
            }
        }
    }
}

int main(){
    DII(n,m);
    cout << n << endl;

    for (int i=1;i<n;i++){
        DII(u,v);
        cout << u << " " << v << endl;

        adj[u].PB(v);
        adj[v].PB(u);
    }

    cout << "DFS OK!\n";
    Dfs(1,0);
    cout << "DFS OK!\n";

    for (int i=1;i<=m;i++){
        DII(u,v);

        query[u].PB(st[v]);
        query[u].PB(ed[v]);
        query[u].PB(st[u]);
        query[u].PB(ed[u]);

        query[v].PB(st[u]);
        query[v].PB(ed[u]);
        query[v].PB(st[v]);
        query[v].PB(ed[v]);
    }

    cout << "QUERY NILAM\n";

    Bfs(1,n);

    cout << cnt << endl;

    for(int i=1;i<=n;i++)       P("%d ",ans[i]);

return 0;
}


/*****************************************************************
 *                   BISMILLAHIR RAHMANIR RAHIM                  *
 *          Raihat Zaman Neloy                                   *
 *          JU-CSE-21                                            *
 *          raihatneloy                                          *
 *****************************************************************/

#include<algorithm>
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<deque>
#include<climits>
#include<complex>

#define S scanf
#define P printf

#define LL long long int
#define ULL unsigned long long int
#define D double

#define Max(a,b)    (a>b?a:b)
#define Min(a,b)    (a<b?a:b)
#define _Max(a,b,c) Max(a,Max(b,c))
#define _Min(a,b,c) Min(a,Min(b,c))
#define SQR(n)      (n*n)
#define PI          2.0*acos(0.0)

#define all(a) a.begin(),a.end()
#define X  first
#define Y  second
#define MP make_pair

#define NL         printf("\n");

#define open       freopen("input.txt","r",stdin)
#define close      freopen ("output.txt","w",stdout)
#define Case(a)    printf("Case %d:",a)
#define caseh(a)   printf("Case #%d: ",a)
#define S1(a)      scanf("%d",&a)
#define S2(a,b)    scanf("%d%d",&a,&b)
#define S3(a,b,c)  scanf("%d%d%d",&a,&b,&c)
#define SL1(a)     scanf("%lld",&a)
#define SL2(a,b)   scanf("%lld%lld",&a,&b)
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define CHR        getchar()
#define PB(x)      push_back(x)
#define pb         push_back
#define PP         pop_back()
#define PF(x)      push_front(x)
#define PPF(x)     pop_front()
#define PS(x)      push(x)
#define sz()       size()
#define UB         upper_bound
#define LB         lower_bound
#define mxe(a,n)   (*max_element(a,a+n))
#define mne(a,n)   (*min_element(a,a+n))
#define SUM(a,n)   (accumulate(a,a+n,0))
#define countbit(x) __builtin_popcount(x)
#define DBG(n)      P("Done %d\n",n);

#define DI(X) int (X);             scanf("%d", &X)
#define DII(X, Y) int X, Y;        scanf("%d%d", &X, &Y)
#define DIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)

#define DILL(X) LL (X); scanf("%lld", &X)

// LOOP
#define repv(i,a) for(int i=0;i<(int)a.size();i++)
#define revv(i,a) for(int i=((int)a.size())-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)

#define FS(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)
#define PR(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++) {  cout << *it << " "; } cout << endl;

#define MEM(a,val) memset(a,val,sizeof(a));
#define SET(a)     memset(a,-1,sizeof a)
#define CLR(a)     memset(a,0,sizeof a)

using namespace std;

template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> T in(){char ch;T n = 0;bool ng = false;while (1){ch = getchar();if (ch == '-'){ng = true;ch = getchar();break;}if (ch>='0' && ch<='9')     break;}while (1){n = n*10 + (ch - '0');ch = getchar();if (ch<'0' || ch>'9')   break;}return (ng?-n:n);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
template <typename T> T Bigmod(T b,T p,T m){ if(p==0) return 1; else if (!(p&1)) return SQR(Bigmod(b,p/2,m)) % m;else return ((b % m) * Bigmod(b,p-1,m)) % m;}
template <typename T> T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
template <typename T> T DIFF(T a,T b) { T d = a-b;if(d<0)return -d;else return d;}
template <typename T> T ABS(T a) {if(a<0)return -a;else return a;}
template <typename T> T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
template <typename T> T euclide(T a,T b,T &x,T &y) {if(a<0){T d=euclide(-a,b,x,y);x=-x;return d;}   if(b<0){T d=euclide(a,-b,x,y);y=-y;return d;}   if(b==0){x=1;y=0;return a;}else{T d=euclide(b,a%b,x,y);T t=x;x=y;y=t-(a/b)*y;return d;}}
template <typename T> void ia (T a[],int n){for (int i=0; i<n; i++) cin >> a[i];}
template <typename T> void pa (T a[],int n){for (int i=0; i<n-1; i++) cout << a[i] << " ";cout << a[n-1] << endl;}
template <typename T> LL isLeft(T a,T b,T c) { return (a.x-b.x)*(b.y-c.y)-(b.x-c.x)*(a.y-b.y); }

int    Set(int N,int pos){ return N=N | (1<<pos);}
int  Reset(int N,int pos){return N= N & ~(1<<pos);}
bool Check(int N,int pos){return (bool)(N & (1<<pos));}
template< class T, class X > inline T   togglebit(T a, X i) { T t=1;return (a^(t<<i)); }

int toInt(string s)  { int sm; stringstream ss(s); ss>>sm; return sm; }
int toLlint(string s) { long long int sm; stringstream ss(s); ss>>sm; return sm;}
int cdigittoint(char ch){return ch-'0';}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
bool isConst(char ch){if (isalpha(ch) && !isVowel(ch)) return true; return false;}

double DEG(double x) { return (180.0*x)/(PI);}
double RAD(double x) { return (x*(double)PI)/(180.0);}

#define VI  vector< int >
#define VII vector< VI >
#define VLL vector< LL >
#define PII pair< int , int >
#define PLL pair< LL , LL >
#define VPI vector< PII >

///         0123456789
#define MX  200007
#define MOD 1000000007
#define INF (1<<30)-1+(1<<30)
#define eps 1e-9

struct Node{
    int sum,lazy;
    Node *l,*r;

    Node(){
        sum = lazy = 0;
        l = r = NULL;
    }
};

VI adj[MX],query[MX];
int st[MX],ed[MX],SubTree[MX];
int node;
Node* Tree[MX];
int ans[MX];

void Dfs(int u,int p){
    st[u] = ++node;
    SubTree[u]++;

    for (int i=0;i<adj[u].size();i++){
        int v = adj[u][i];

        if (v != p)     Dfs(v,u),SubTree[u] += SubTree[v];
    }

    ed[u] = node;
}

Node* Propagate(int l,int r){
    Node* u = new Node();

    u->lazy = 1;
    u->sum = (r-l+1);
    u->l = u->r = NULL;
}

Node* Update(Node *idx,int l,int r,int s,int e){
    if (idx != NULL && idx->lazy)       return idx;

    Node *u = new Node();

    if (idx != NULL)        *u = *idx;

    if(s == l && e == r){
        u->sum = (r-l+1);
        u->lazy = 1;
        u->l = u->r = NULL;

        return u;
    }

    int mid = (l+r)>>1;

    if (e <= mid)       u->l = Update(u->l,l,mid,s,e);
    else if (s > mid)   u->r = Update(u->r,mid+1,r,s,e);
    else{
        u->l = Update(u->l,l,mid,s,mid);
        u->r = Update(u->r,mid+1,r,mid+1,e);
    }

    u->sum = 0;

    if (u->l != NULL)       u->sum += u->l->sum;
    if (u->r != NULL)       u->sum += u->r->sum;

    return u;
}

void Bfs(int s,int n){
    Tree[0] = NULL;

    queue<int> q;

    q.PS(s);
    q.PS(0);

    while (!q.empty()){
        int u = q.front();q.pop();
        int p = q.front();q.pop();

        Tree[u] = Tree[p];

        for (int i=0;i<query[u].size();i+=2){
            int x = query[u][i];
            int y = query[u][i+1];

            Tree[u] = Update(Tree[u],1,n,x,y);
        }

        ans[u] = (Tree[u]==NULL?0:Tree[u]->sum-1);

        for (int i=0;i<adj[u].size();i++){
            int v = adj[u][i];

            if (v != p){
                q.PS(v);
                q.PS(u);
            }
        }
    }
}

int main(){
    DII(n,m);

    for (int i=1;i<n;i++){
        DII(u,v);

        adj[u].PB(v);
        adj[v].PB(u);
    }

    Dfs(1,0);
//    cout << "DFS OK!\n";

    for (int i=1;i<=m;i++){
        DII(u,v);

        query[u].PB(st[v]);
        query[u].PB(ed[v]);
        query[u].PB(st[u]);
        query[u].PB(ed[u]);

        query[v].PB(st[u]);
        query[v].PB(ed[u]);
        query[v].PB(st[v]);
        query[v].PB(ed[v]);
    }

//    cout << "QUERY NILAM\n";

    Bfs(1,n);

    for(int i=1;i<=n;i++)       P("%d ",ans[i]);

return 0;
}


/*****************************************************************
 *                   BISMILLAHIR RAHMANIR RAHIM                  *
 *          Raihat Zaman Neloy                                   *
 *          JU-CSE-21                                            *
 *          raihatneloy                                          *
 *****************************************************************/

#include<algorithm>
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<deque>
#include<climits>
#include<complex>

#define S scanf
#define P printf

#define LL long long int
#define ULL unsigned long long int
#define D double

#define Max(a,b)    (a>b?a:b)
#define Min(a,b)    (a<b?a:b)
#define _Max(a,b,c) Max(a,Max(b,c))
#define _Min(a,b,c) Min(a,Min(b,c))
#define SQR(n)      (n*n)
#define PI          2.0*acos(0.0)

#define all(a) a.begin(),a.end()
#define X  first
#define Y  second
#define MP make_pair

#define NL         printf("\n");

#define open       freopen("input.txt","r",stdin)
#define close      freopen ("output.txt","w",stdout)
#define Case(a)    printf("Case %d:",a)
#define caseh(a)   printf("Case #%d: ",a)
#define S1(a)      scanf("%d",&a)
#define S2(a,b)    scanf("%d%d",&a,&b)
#define S3(a,b,c)  scanf("%d%d%d",&a,&b,&c)
#define SL1(a)     scanf("%lld",&a)
#define SL2(a,b)   scanf("%lld%lld",&a,&b)
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define CHR        getchar()
#define PB(x)      push_back(x)
#define pb         push_back
#define PP         pop_back()
#define PF(x)      push_front(x)
#define PPF(x)     pop_front()
#define PS(x)      push(x)
#define sz()       size()
#define UB         upper_bound
#define LB         lower_bound
#define mxe(a,n)   (*max_element(a,a+n))
#define mne(a,n)   (*min_element(a,a+n))
#define SUM(a,n)   (accumulate(a,a+n,0))
#define countbit(x) __builtin_popcount(x)
#define DBG(n)      P("Done %d\n",n);

#define DI(X) int (X);             scanf("%d", &X)
#define DII(X, Y) int X, Y;        scanf("%d%d", &X, &Y)
#define DIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)

#define DILL(X) LL (X); scanf("%lld", &X)

// LOOP
#define repv(i,a) for(int i=0;i<(int)a.size();i++)
#define revv(i,a) for(int i=((int)a.size())-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)

#define FS(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)
#define PR(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++) {  cout << *it << " "; } cout << endl;

#define MEM(a,val) memset(a,val,sizeof(a));
#define SET(a)     memset(a,-1,sizeof a)
#define CLR(a)     memset(a,0,sizeof a)

using namespace std;

template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> T in(){char ch;T n = 0;bool ng = false;while (1){ch = getchar();if (ch == '-'){ng = true;ch = getchar();break;}if (ch>='0' && ch<='9')     break;}while (1){n = n*10 + (ch - '0');ch = getchar();if (ch<'0' || ch>'9')   break;}return (ng?-n:n);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
template <typename T> T Bigmod(T b,T p,T m){ if(p==0) return 1; else if (!(p&1)) return SQR(Bigmod(b,p/2,m)) % m;else return ((b % m) * Bigmod(b,p-1,m)) % m;}
template <typename T> T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
template <typename T> T DIFF(T a,T b) { T d = a-b;if(d<0)return -d;else return d;}
template <typename T> T ABS(T a) {if(a<0)return -a;else return a;}
template <typename T> T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
template <typename T> T euclide(T a,T b,T &x,T &y) {if(a<0){T d=euclide(-a,b,x,y);x=-x;return d;}   if(b<0){T d=euclide(a,-b,x,y);y=-y;return d;}   if(b==0){x=1;y=0;return a;}else{T d=euclide(b,a%b,x,y);T t=x;x=y;y=t-(a/b)*y;return d;}}
template <typename T> void ia (T a[],int n){for (int i=0; i<n; i++) cin >> a[i];}
template <typename T> void pa (T a[],int n){for (int i=0; i<n-1; i++) cout << a[i] << " ";cout << a[n-1] << endl;}
template <typename T> LL isLeft(T a,T b,T c) { return (a.x-b.x)*(b.y-c.y)-(b.x-c.x)*(a.y-b.y); }

int    Set(int N,int pos){ return N=N | (1<<pos);}
int  Reset(int N,int pos){return N= N & ~(1<<pos);}
bool Check(int N,int pos){return (bool)(N & (1<<pos));}
template< class T, class X > inline T   togglebit(T a, X i) { T t=1;return (a^(t<<i)); }

int toInt(string s)  { int sm; stringstream ss(s); ss>>sm; return sm; }
int toLlint(string s) { long long int sm; stringstream ss(s); ss>>sm; return sm;}
int cdigittoint(char ch){return ch-'0';}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
bool isConst(char ch){if (isalpha(ch) && !isVowel(ch)) return true; return false;}

double DEG(double x) { return (180.0*x)/(PI);}
double RAD(double x) { return (x*(double)PI)/(180.0);}

#define VI  vector< int >
#define VII vector< VI >
#define VLL vector< LL >
#define PII pair< int , int >
#define PLL pair< LL , LL >
#define VPI vector< PII >

///         0123456789
#define MX  200007
#define MOD 1000000007
#define INF (1<<30)-1+(1<<30)
#define eps 1e-9

struct Node{
    int sum,lazy;
    Node *l,*r;

    Node(){
        sum = lazy = 0;
        l = r = NULL;
    }
};

VI adj[MX],query[MX];
int st[MX],ed[MX];
int node;
Node* Tree[MX];
Node Nodes[1000007];
int cnt;
int ans[MX];

void Dfs(int u,int p){
    st[u] = ++node;

    for (int i=0;i<adj[u].size();i++){
        int v = adj[u][i];

        if (v != p)     Dfs(v,u);
    }

    ed[u] = node;
}

Node* Propagate(Node *u,int l,int r){
    if (u == NULL)  u = &Nodes[++cnt];

    u->lazy = 1;
    u->sum = (r-l+1);
    u->l = u->r = NULL;
}

Node* Update(Node *idx,int l,int r,int s,int e){
    Node *u = &Nodes[++cnt];

    if (idx != NULL)        *u = *idx;

    if(s == l && e == r)    return Propagate(u,l,r);

    int mid = (l+r)>>1;

    if (u->lazy){
        u->l = Propagate(u->l,l,mid);
        u->r = Propagate(u->r,mid+1,r);
    }

    if (e <= mid)       u->l = Update(u->l,l,mid,s,e);
    else if (s > mid)   u->r = Update(u->r,mid+1,r,s,e);
    else{
        u->l = Update(u->l,l,mid,s,mid);
        u->r = Update(u->r,mid+1,r,mid+1,e);
    }

    u->sum = 0;

    if (u->l != NULL)       u->sum += u->l->sum;
    if (u->r != NULL)       u->sum += u->r->sum;

    return u;
}

void Bfs(int s,int n){
    Tree[0] = NULL;

    queue<int> q;

    q.PS(s);
    q.PS(0);

    while (!q.empty()){
        int u = q.front();q.pop();
        int p = q.front();q.pop();

        Tree[u] = Tree[p];

        for (int i=0;i<query[u].size();i+=2){
            int x = query[u][i];
            int y = query[u][i+1];

            Tree[u] = Update(Tree[u],1,n,x,y);
        }

        ans[u] = (Tree[u]==NULL?0:Tree[u]->sum-1);

        for (int i=0;i<adj[u].size();i++){
            int v = adj[u][i];

            if (v != p){
                q.PS(v);
                q.PS(u);
            }
        }
    }
}

int main(){
    DII(n,m);
    cout << n << endl;

    for (int i=1;i<n;i++){
        DII(u,v);

        adj[u].PB(v);
        adj[v].PB(u);
    }

    Dfs(1,0);
    cout << "DFS OK!\n";

    for (int i=1;i<=m;i++){
        DII(u,v);

        query[u].PB(st[v]);
        query[u].PB(ed[v]);
        query[u].PB(st[u]);
        query[u].PB(ed[u]);

        query[v].PB(st[u]);
        query[v].PB(ed[u]);
        query[v].PB(st[v]);
        query[v].PB(ed[v]);
    }

    cout << "QUERY NILAM\n";

    Bfs(1,n);

    cout << cnt << endl;

    for(int i=1;i<=n;i++)       P("%d ",ans[i]);

return 0;
}


/*****************************************************************
 *                   BISMILLAHIR RAHMANIR RAHIM                  *
 *          Raihat Zaman Neloy                                   *
 *          JU-CSE-21                                            *
 *          raihatneloy                                          *
 *****************************************************************/

#include<algorithm>
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<deque>
#include<climits>
#include<complex>

#define S scanf
#define P printf

#define LL long long int
#define ULL unsigned long long int
#define D double

#define Max(a,b)    (a>b?a:b)
#define Min(a,b)    (a<b?a:b)
#define _Max(a,b,c) Max(a,Max(b,c))
#define _Min(a,b,c) Min(a,Min(b,c))
#define SQR(n)      (n*n)
#define PI          2.0*acos(0.0)

#define all(a) a.begin(),a.end()
#define X  first
#define Y  second
#define MP make_pair

#define NL         printf("\n");

#define open       freopen("input.txt","r",stdin)
#define close      freopen ("output.txt","w",stdout)
#define Case(a)    printf("Case %d:",a)
#define caseh(a)   printf("Case #%d: ",a)
#define S1(a)      scanf("%d",&a)
#define S2(a,b)    scanf("%d%d",&a,&b)
#define S3(a,b,c)  scanf("%d%d%d",&a,&b,&c)
#define SL1(a)     scanf("%lld",&a)
#define SL2(a,b)   scanf("%lld%lld",&a,&b)
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define CHR        getchar()
#define PB(x)      push_back(x)
#define pb         push_back
#define PP         pop_back()
#define PF(x)      push_front(x)
#define PPF(x)     pop_front()
#define PS(x)      push(x)
#define sz()       size()
#define UB         upper_bound
#define LB         lower_bound
#define mxe(a,n)   (*max_element(a,a+n))
#define mne(a,n)   (*min_element(a,a+n))
#define SUM(a,n)   (accumulate(a,a+n,0))
#define countbit(x) __builtin_popcount(x)
#define DBG(n)      P("Done %d\n",n);

#define DI(X) int (X);             scanf("%d", &X)
#define DII(X, Y) int X, Y;        scanf("%d%d", &X, &Y)
#define DIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)

#define DILL(X) LL (X); scanf("%lld", &X)

// LOOP
#define repv(i,a) for(int i=0;i<(int)a.size();i++)
#define revv(i,a) for(int i=((int)a.size())-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)

#define FS(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)
#define PR(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++) {  cout << *it << " "; } cout << endl;

#define MEM(a,val) memset(a,val,sizeof(a));
#define SET(a)     memset(a,-1,sizeof a)
#define CLR(a)     memset(a,0,sizeof a)

using namespace std;

template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> T in(){char ch;T n = 0;bool ng = false;while (1){ch = getchar();if (ch == '-'){ng = true;ch = getchar();break;}if (ch>='0' && ch<='9')     break;}while (1){n = n*10 + (ch - '0');ch = getchar();if (ch<'0' || ch>'9')   break;}return (ng?-n:n);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
template <typename T> T Bigmod(T b,T p,T m){ if(p==0) return 1; else if (!(p&1)) return SQR(Bigmod(b,p/2,m)) % m;else return ((b % m) * Bigmod(b,p-1,m)) % m;}
template <typename T> T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
template <typename T> T DIFF(T a,T b) { T d = a-b;if(d<0)return -d;else return d;}
template <typename T> T ABS(T a) {if(a<0)return -a;else return a;}
template <typename T> T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
template <typename T> T euclide(T a,T b,T &x,T &y) {if(a<0){T d=euclide(-a,b,x,y);x=-x;return d;}   if(b<0){T d=euclide(a,-b,x,y);y=-y;return d;}   if(b==0){x=1;y=0;return a;}else{T d=euclide(b,a%b,x,y);T t=x;x=y;y=t-(a/b)*y;return d;}}
template <typename T> void ia (T a[],int n){for (int i=0; i<n; i++) cin >> a[i];}
template <typename T> void pa (T a[],int n){for (int i=0; i<n-1; i++) cout << a[i] << " ";cout << a[n-1] << endl;}
template <typename T> LL isLeft(T a,T b,T c) { return (a.x-b.x)*(b.y-c.y)-(b.x-c.x)*(a.y-b.y); }

int    Set(int N,int pos){ return N=N | (1<<pos);}
int  Reset(int N,int pos){return N= N & ~(1<<pos);}
bool Check(int N,int pos){return (bool)(N & (1<<pos));}
template< class T, class X > inline T   togglebit(T a, X i) { T t=1;return (a^(t<<i)); }

int toInt(string s)  { int sm; stringstream ss(s); ss>>sm; return sm; }
int toLlint(string s) { long long int sm; stringstream ss(s); ss>>sm; return sm;}
int cdigittoint(char ch){return ch-'0';}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
bool isConst(char ch){if (isalpha(ch) && !isVowel(ch)) return true; return false;}

double DEG(double x) { return (180.0*x)/(PI);}
double RAD(double x) { return (x*(double)PI)/(180.0);}

#define VI  vector< int >
#define VII vector< VI >
#define VLL vector< LL >
#define PII pair< int , int >
#define PLL pair< LL , LL >
#define VPI vector< PII >

///         0123456789
#define MX  200007
#define MOD 1000000007
#define INF (1<<30)-1+(1<<30)
#define eps 1e-9

struct Node{
    int sum,lazy;
    Node *l,*r;

    Node(){
        sum = lazy = 0;
        l = r = NULL;
    }
};

VI adj[MX],query[MX];
int st[MX],ed[MX];
int node;
Node* Tree[MX];
Node Nodes[1000007];
int cnt;
int ans[MX];

void Dfs(int u,int p){
    st[u] = ++node;

    for (int i=0;i<adj[u].size();i++){
        int v = adj[u][i];

        if (v != p)     Dfs(v,u);
    }

    ed[u] = node;
}

Node* Propagate(Node *u,int l,int r){
    if (u == NULL)  u = &Nodes[++cnt];

    u->lazy = 1;
    u->sum = (r-l+1);
    u->l = u->r = NULL;
}

Node* Update(Node *idx,int l,int r,int s,int e){
    Node *u = &Nodes[++cnt];

    if (idx != NULL)        *u = *idx;

    if(s == l && e == r)    return Propagate(u,l,r);

    int mid = (l+r)>>1;

    if (u->lazy){
        u->l = Propagate(u->l,l,mid);
        u->r = Propagate(u->r,mid+1,r);
    }

    if (e <= mid)       u->l = Update(u->l,l,mid,s,e);
    else if (s > mid)   u->r = Update(u->r,mid+1,r,s,e);
    else{
        u->l = Update(u->l,l,mid,s,mid);
        u->r = Update(u->r,mid+1,r,mid+1,e);
    }

    u->sum = 0;

    if (u->l != NULL)       u->sum += u->l->sum;
    if (u->r != NULL)       u->sum += u->r->sum;

    return u;
}

void Bfs(int s,int n){
    Tree[0] = NULL;

    queue<int> q;

    q.PS(s);
    q.PS(0);

    while (!q.empty()){
        int u = q.front();q.pop();
        int p = q.front();q.pop();

        Tree[u] = Tree[p];

        for (int i=0;i<query[u].size();i+=2){
            int x = query[u][i];
            int y = query[u][i+1];

            Tree[u] = Update(Tree[u],1,n,x,y);
        }

        ans[u] = (Tree[u]==NULL?0:Tree[u]->sum-1);

        for (int i=0;i<adj[u].size();i++){
            int v = adj[u][i];

            if (v != p){
                q.PS(v);
                q.PS(u);
            }
        }
    }
}

int main(){
    DII(n,m);
    cout << n << endl;

    for (int i=1;i<n;i++){
        DII(u,v);
        cout << u << " " << v << endl;

        adj[u].PB(v);
        adj[v].PB(u);
    }
    cout << m << endl;
    cout << "DFS OK!\n";
    Dfs(1,0);
    cout << "DFS OK!\n";

    for (int i=1;i<=m;i++){
        DII(u,v);

        query[u].PB(st[v]);
        query[u].PB(ed[v]);
        query[u].PB(st[u]);
        query[u].PB(ed[u]);

        query[v].PB(st[u]);
        query[v].PB(ed[u]);
        query[v].PB(st[v]);
        query[v].PB(ed[v]);
    }

    cout << "QUERY NILAM\n";

/*    Bfs(1,n);

    cout << cnt << endl;

    for(int i=1;i<=n;i++)       P("%d ",ans[i]);
*/
return 0;
}


/*****************************************************************
 *                   BISMILLAHIR RAHMANIR RAHIM                  *
 *          Raihat Zaman Neloy                                   *
 *          JU-CSE-21                                            *
 *          raihatneloy                                          *
 *****************************************************************/

#include<algorithm>
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<deque>
#include<climits>
#include<complex>

#define S scanf
#define P printf

#define LL long long int
#define ULL unsigned long long int
#define D double

#define Max(a,b)    (a>b?a:b)
#define Min(a,b)    (a<b?a:b)
#define _Max(a,b,c) Max(a,Max(b,c))
#define _Min(a,b,c) Min(a,Min(b,c))
#define SQR(n)      (n*n)
#define PI          2.0*acos(0.0)

#define all(a) a.begin(),a.end()
#define X  first
#define Y  second
#define MP make_pair

#define NL         printf("\n");

#define open       freopen("input.txt","r",stdin)
#define close      freopen ("output.txt","w",stdout)
#define Case(a)    printf("Case %d:",a)
#define caseh(a)   printf("Case #%d: ",a)
#define S1(a)      scanf("%d",&a)
#define S2(a,b)    scanf("%d%d",&a,&b)
#define S3(a,b,c)  scanf("%d%d%d",&a,&b,&c)
#define SL1(a)     scanf("%lld",&a)
#define SL2(a,b)   scanf("%lld%lld",&a,&b)
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define CHR        getchar()
#define PB(x)      push_back(x)
#define pb         push_back
#define PP         pop_back()
#define PF(x)      push_front(x)
#define PPF(x)     pop_front()
#define PS(x)      push(x)
#define sz()       size()
#define UB         upper_bound
#define LB         lower_bound
#define mxe(a,n)   (*max_element(a,a+n))
#define mne(a,n)   (*min_element(a,a+n))
#define SUM(a,n)   (accumulate(a,a+n,0))
#define countbit(x) __builtin_popcount(x)
#define DBG(n)      P("Done %d\n",n);

#define DI(X) int (X);             scanf("%d", &X)
#define DII(X, Y) int X, Y;        scanf("%d%d", &X, &Y)
#define DIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)

#define DILL(X) LL (X); scanf("%lld", &X)

// LOOP
#define repv(i,a) for(int i=0;i<(int)a.size();i++)
#define revv(i,a) for(int i=((int)a.size())-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)

#define FS(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)
#define PR(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++) {  cout << *it << " "; } cout << endl;

#define MEM(a,val) memset(a,val,sizeof(a));
#define SET(a)     memset(a,-1,sizeof a)
#define CLR(a)     memset(a,0,sizeof a)

using namespace std;

template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> T in(){char ch;T n = 0;bool ng = false;while (1){ch = getchar();if (ch == '-'){ng = true;ch = getchar();break;}if (ch>='0' && ch<='9')     break;}while (1){n = n*10 + (ch - '0');ch = getchar();if (ch<'0' || ch>'9')   break;}return (ng?-n:n);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
template <typename T> T Bigmod(T b,T p,T m){ if(p==0) return 1; else if (!(p&1)) return SQR(Bigmod(b,p/2,m)) % m;else return ((b % m) * Bigmod(b,p-1,m)) % m;}
template <typename T> T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
template <typename T> T DIFF(T a,T b) { T d = a-b;if(d<0)return -d;else return d;}
template <typename T> T ABS(T a) {if(a<0)return -a;else return a;}
template <typename T> T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
template <typename T> T euclide(T a,T b,T &x,T &y) {if(a<0){T d=euclide(-a,b,x,y);x=-x;return d;}   if(b<0){T d=euclide(a,-b,x,y);y=-y;return d;}   if(b==0){x=1;y=0;return a;}else{T d=euclide(b,a%b,x,y);T t=x;x=y;y=t-(a/b)*y;return d;}}
template <typename T> void ia (T a[],int n){for (int i=0; i<n; i++) cin >> a[i];}
template <typename T> void pa (T a[],int n){for (int i=0; i<n-1; i++) cout << a[i] << " ";cout << a[n-1] << endl;}
template <typename T> LL isLeft(T a,T b,T c) { return (a.x-b.x)*(b.y-c.y)-(b.x-c.x)*(a.y-b.y); }

int    Set(int N,int pos){ return N=N | (1<<pos);}
int  Reset(int N,int pos){return N= N & ~(1<<pos);}
bool Check(int N,int pos){return (bool)(N & (1<<pos));}
template< class T, class X > inline T   togglebit(T a, X i) { T t=1;return (a^(t<<i)); }

int toInt(string s)  { int sm; stringstream ss(s); ss>>sm; return sm; }
int toLlint(string s) { long long int sm; stringstream ss(s); ss>>sm; return sm;}
int cdigittoint(char ch){return ch-'0';}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
bool isConst(char ch){if (isalpha(ch) && !isVowel(ch)) return true; return false;}

double DEG(double x) { return (180.0*x)/(PI);}
double RAD(double x) { return (x*(double)PI)/(180.0);}

#define VI  vector< int >
#define VII vector< VI >
#define VLL vector< LL >
#define PII pair< int , int >
#define PLL pair< LL , LL >
#define VPI vector< PII >

///         0123456789
#define MX  200007
#define MOD 1000000007
#define INF (1<<30)-1+(1<<30)
#define eps 1e-9

struct Node{
    int sum,lazy;
    Node *l,*r;

    Node(){
        sum = lazy = 0;
        l = r = NULL;
    }
};

VI adj[MX],query[MX];
int st[MX],ed[MX];
int node;
Node* Tree[MX];
Node Nodes[1000007];
int cnt;
int ans[MX];

void Dfs(int u,int p){
    st[u] = ++node;

    for (int i=0;i<adj[u].size();i++){
        int v = adj[u][i];

        if (v != p)     Dfs(v,u);
    }

    ed[u] = node;
}

Node* Propagate(Node *u,int l,int r){
    if (u == NULL)  u = &Nodes[++cnt];

    u->lazy = 1;
    u->sum = (r-l+1);
    u->l = u->r = NULL;
}

Node* Update(Node *idx,int l,int r,int s,int e){
    Node *u = &Nodes[++cnt];

    if (idx != NULL)        *u = *idx;

    if(s == l && e == r)    return Propagate(u,l,r);

    int mid = (l+r)>>1;

    if (u->lazy){
        u->l = Propagate(u->l,l,mid);
        u->r = Propagate(u->r,mid+1,r);
    }

    if (e <= mid)       u->l = Update(u->l,l,mid,s,e);
    else if (s > mid)   u->r = Update(u->r,mid+1,r,s,e);
    else{
        u->l = Update(u->l,l,mid,s,mid);
        u->r = Update(u->r,mid+1,r,mid+1,e);
    }

    u->sum = 0;

    if (u->l != NULL)       u->sum += u->l->sum;
    if (u->r != NULL)       u->sum += u->r->sum;

    return u;
}

void Bfs(int s,int n){
    Tree[0] = NULL;

    queue<int> q;

    q.PS(s);
    q.PS(0);

    while (!q.empty()){
        int u = q.front();q.pop();
        int p = q.front();q.pop();

        Tree[u] = Tree[p];

        for (int i=0;i<query[u].size();i+=2){
            int x = query[u][i];
            int y = query[u][i+1];

            Tree[u] = Update(Tree[u],1,n,x,y);
        }

        ans[u] = (Tree[u]==NULL?0:Tree[u]->sum-1);

        for (int i=0;i<adj[u].size();i++){
            int v = adj[u][i];

            if (v != p){
                q.PS(v);
                q.PS(u);
            }
        }
    }
}

int main(){
    DII(n,m);
    cout << n << endl;

    for (int i=1;i<n;i++){
        DII(u,v);

        adj[u].PB(v);
        adj[v].PB(u);
    }

    cout << "DFS OK!\n";
    Dfs(1,0);
    cout << "DFS OK!\n";

    for (int i=1;i<=m;i++){
        DII(u,v);

        query[u].PB(st[v]);
        query[u].PB(ed[v]);
        query[u].PB(st[u]);
        query[u].PB(ed[u]);

        query[v].PB(st[u]);
        query[v].PB(ed[u]);
        query[v].PB(st[v]);
        query[v].PB(ed[v]);
    }

    cout << "QUERY NILAM\n";

    Bfs(1,n);

    cout << cnt << endl;

    for(int i=1;i<=n;i++)       P("%d ",ans[i]);

return 0;
}


/*****************************************************************
 *                   BISMILLAHIR RAHMANIR RAHIM                  *
 *          Raihat Zaman Neloy                                   *
 *          JU-CSE-21                                            *
 *          raihatneloy                                          *
 *****************************************************************/

#include<algorithm>
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<deque>
#include<climits>
#include<complex>

#define S scanf
#define P printf

#define LL long long int
#define ULL unsigned long long int
#define D double

#define Max(a,b)    (a>b?a:b)
#define Min(a,b)    (a<b?a:b)
#define _Max(a,b,c) Max(a,Max(b,c))
#define _Min(a,b,c) Min(a,Min(b,c))
#define SQR(n)      (n*n)
#define PI          2.0*acos(0.0)

#define all(a) a.begin(),a.end()
#define X  first
#define Y  second
#define MP make_pair

#define NL         printf("\n");

#define open       freopen("input.txt","r",stdin)
#define close      freopen ("output.txt","w",stdout)
#define Case(a)    printf("Case %d:",a)
#define caseh(a)   printf("Case #%d: ",a)
#define S1(a)      scanf("%d",&a)
#define S2(a,b)    scanf("%d%d",&a,&b)
#define S3(a,b,c)  scanf("%d%d%d",&a,&b,&c)
#define SL1(a)     scanf("%lld",&a)
#define SL2(a,b)   scanf("%lld%lld",&a,&b)
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define CHR        getchar()
#define PB(x)      push_back(x)
#define pb         push_back
#define PP         pop_back()
#define PF(x)      push_front(x)
#define PPF(x)     pop_front()
#define PS(x)      push(x)
#define sz()       size()
#define UB         upper_bound
#define LB         lower_bound
#define mxe(a,n)   (*max_element(a,a+n))
#define mne(a,n)   (*min_element(a,a+n))
#define SUM(a,n)   (accumulate(a,a+n,0))
#define countbit(x) __builtin_popcount(x)
#define DBG(n)      P("Done %d\n",n);

#define DI(X) int (X);             scanf("%d", &X)
#define DII(X, Y) int X, Y;        scanf("%d%d", &X, &Y)
#define DIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)

#define DILL(X) LL (X); scanf("%lld", &X)

// LOOP
#define repv(i,a) for(int i=0;i<(int)a.size();i++)
#define revv(i,a) for(int i=((int)a.size())-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)

#define FS(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)
#define PR(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++) {  cout << *it << " "; } cout << endl;

#define MEM(a,val) memset(a,val,sizeof(a));
#define SET(a)     memset(a,-1,sizeof a)
#define CLR(a)     memset(a,0,sizeof a)

using namespace std;

template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> T in(){char ch;T n = 0;bool ng = false;while (1){ch = getchar();if (ch == '-'){ng = true;ch = getchar();break;}if (ch>='0' && ch<='9')     break;}while (1){n = n*10 + (ch - '0');ch = getchar();if (ch<'0' || ch>'9')   break;}return (ng?-n:n);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
template <typename T> T Bigmod(T b,T p,T m){ if(p==0) return 1; else if (!(p&1)) return SQR(Bigmod(b,p/2,m)) % m;else return ((b % m) * Bigmod(b,p-1,m)) % m;}
template <typename T> T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
template <typename T> T DIFF(T a,T b) { T d = a-b;if(d<0)return -d;else return d;}
template <typename T> T ABS(T a) {if(a<0)return -a;else return a;}
template <typename T> T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
template <typename T> T euclide(T a,T b,T &x,T &y) {if(a<0){T d=euclide(-a,b,x,y);x=-x;return d;}   if(b<0){T d=euclide(a,-b,x,y);y=-y;return d;}   if(b==0){x=1;y=0;return a;}else{T d=euclide(b,a%b,x,y);T t=x;x=y;y=t-(a/b)*y;return d;}}
template <typename T> void ia (T a[],int n){for (int i=0; i<n; i++) cin >> a[i];}
template <typename T> void pa (T a[],int n){for (int i=0; i<n-1; i++) cout << a[i] << " ";cout << a[n-1] << endl;}
template <typename T> LL isLeft(T a,T b,T c) { return (a.x-b.x)*(b.y-c.y)-(b.x-c.x)*(a.y-b.y); }

int    Set(int N,int pos){ return N=N | (1<<pos);}
int  Reset(int N,int pos){return N= N & ~(1<<pos);}
bool Check(int N,int pos){return (bool)(N & (1<<pos));}
template< class T, class X > inline T   togglebit(T a, X i) { T t=1;return (a^(t<<i)); }

int toInt(string s)  { int sm; stringstream ss(s); ss>>sm; return sm; }
int toLlint(string s) { long long int sm; stringstream ss(s); ss>>sm; return sm;}
int cdigittoint(char ch){return ch-'0';}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
bool isConst(char ch){if (isalpha(ch) && !isVowel(ch)) return true; return false;}

double DEG(double x) { return (180.0*x)/(PI);}
double RAD(double x) { return (x*(double)PI)/(180.0);}

#define VI  vector< int >
#define VII vector< VI >
#define VLL vector< LL >
#define PII pair< int , int >
#define PLL pair< LL , LL >
#define VPI vector< PII >

///         0123456789
#define MX  200007
#define MOD 1000000007
#define INF (1<<30)-1+(1<<30)
#define eps 1e-9

struct Node{
    int sum,lazy;
    Node *l,*r;

    Node(){
        sum = lazy = 0;
        l = r = NULL;
    }
};

VI adj[MX],query[MX];
int st[MX],ed[MX];
int node;
Node* Tree[MX];
Node Nodes[1000007];
int cnt;
int ans[MX];

void Dfs(int u,int p){
    st[u] = ++node;

    for (int i=0;i<adj[u].size();i++){
        int v = adj[u][i];

        if (v != p)     Dfs(v,u);
    }

    ed[u] = node;
}

Node* Propagate(Node *u,int l,int r){
    if (u == NULL)  u = &Nodes[++cnt];

    u->lazy = 1;
    u->sum = (r-l+1);
    u->l = u->r = NULL;
}

Node* Update(Node *idx,int l,int r,int s,int e){
    Node *u = &Nodes[++cnt];

    if (idx != NULL)        *u = *idx;

    if(s == l && e == r)    return Propagate(u,l,r);

    int mid = (l+r)>>1;

    if (u->lazy){
        u->l = Propagate(u->l,l,mid);
        u->r = Propagate(u->r,mid+1,r);
    }

    if (e <= mid)       u->l = Update(u->l,l,mid,s,e);
    else if (s > mid)   u->r = Update(u->r,mid+1,r,s,e);
    else{
        u->l = Update(u->l,l,mid,s,mid);
        u->r = Update(u->r,mid+1,r,mid+1,e);
    }

    u->sum = 0;

    if (u->l != NULL)       u->sum += u->l->sum;
    if (u->r != NULL)       u->sum += u->r->sum;

    return u;
}

void Bfs(int s,int n){
    Tree[0] = NULL;

    queue<int> q;

    q.PS(s);
    q.PS(0);

    while (!q.empty()){
        int u = q.front();q.pop();
        int p = q.front();q.pop();

        Tree[u] = Tree[p];

        for (int i=0;i<query[u].size();i+=2){
            int x = query[u][i];
            int y = query[u][i+1];

            Tree[u] = Update(Tree[u],1,n,x,y);
        }

        ans[u] = (Tree[u]==NULL?0:Tree[u]->sum-1);

        for (int i=0;i<adj[u].size();i++){
            int v = adj[u][i];

            if (v != p){
                q.PS(v);
                q.PS(u);
            }
        }
    }
}

int main(){
    DII(n,m);
    cout << n << endl;

    for (int i=1;i<n;i++){
        DII(u,v);
        cout << u << " " << v << endl;

        adj[u].PB(v);
        adj[v].PB(u);
    }
    cout << m << endl;
    cout << "DFS OK!\n";
    Dfs(1,0);
    cout << "DFS OK!\n";
/*
    for (int i=1;i<=m;i++){
        DII(u,v);

        query[u].PB(st[v]);
        query[u].PB(ed[v]);
        query[u].PB(st[u]);
        query[u].PB(ed[u]);

        query[v].PB(st[u]);
        query[v].PB(ed[u]);
        query[v].PB(st[v]);
        query[v].PB(ed[v]);
    }

    cout << "QUERY NILAM\n";

    Bfs(1,n);

    cout << cnt << endl;

    for(int i=1;i<=n;i++)       P("%d ",ans[i]);
*/
return 0;
}


/*****************************************************************
 *                   BISMILLAHIR RAHMANIR RAHIM                  *
 *          Raihat Zaman Neloy                                   *
 *          JU-CSE-21                                            *
 *          raihatneloy                                          *
 *****************************************************************/

#include<algorithm>
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<deque>
#include<climits>
#include<complex>

#define S scanf
#define P printf

#define LL long long int
#define ULL unsigned long long int
#define D double

#define Max(a,b)    (a>b?a:b)
#define Min(a,b)    (a<b?a:b)
#define _Max(a,b,c) Max(a,Max(b,c))
#define _Min(a,b,c) Min(a,Min(b,c))
#define SQR(n)      (n*n)
#define PI          2.0*acos(0.0)

#define all(a) a.begin(),a.end()
#define X  first
#define Y  second
#define MP make_pair

#define NL         printf("\n");

#define open       freopen("input.txt","r",stdin)
#define close      freopen ("output.txt","w",stdout)
#define Case(a)    printf("Case %d:",a)
#define caseh(a)   printf("Case #%d: ",a)
#define S1(a)      scanf("%d",&a)
#define S2(a,b)    scanf("%d%d",&a,&b)
#define S3(a,b,c)  scanf("%d%d%d",&a,&b,&c)
#define SL1(a)     scanf("%lld",&a)
#define SL2(a,b)   scanf("%lld%lld",&a,&b)
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define CHR        getchar()
#define PB(x)      push_back(x)
#define pb         push_back
#define PP         pop_back()
#define PF(x)      push_front(x)
#define PPF(x)     pop_front()
#define PS(x)      push(x)
#define sz()       size()
#define UB         upper_bound
#define LB         lower_bound
#define mxe(a,n)   (*max_element(a,a+n))
#define mne(a,n)   (*min_element(a,a+n))
#define SUM(a,n)   (accumulate(a,a+n,0))
#define countbit(x) __builtin_popcount(x)
#define DBG(n)      P("Done %d\n",n);

#define DI(X) int (X);             scanf("%d", &X)
#define DII(X, Y) int X, Y;        scanf("%d%d", &X, &Y)
#define DIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)

#define DILL(X) LL (X); scanf("%lld", &X)

// LOOP
#define repv(i,a) for(int i=0;i<(int)a.size();i++)
#define revv(i,a) for(int i=((int)a.size())-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)

#define FS(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)
#define PR(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++) {  cout << *it << " "; } cout << endl;

#define MEM(a,val) memset(a,val,sizeof(a));
#define SET(a)     memset(a,-1,sizeof a)
#define CLR(a)     memset(a,0,sizeof a)

using namespace std;

template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> T in(){char ch;T n = 0;bool ng = false;while (1){ch = getchar();if (ch == '-'){ng = true;ch = getchar();break;}if (ch>='0' && ch<='9')     break;}while (1){n = n*10 + (ch - '0');ch = getchar();if (ch<'0' || ch>'9')   break;}return (ng?-n:n);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
template <typename T> T Bigmod(T b,T p,T m){ if(p==0) return 1; else if (!(p&1)) return SQR(Bigmod(b,p/2,m)) % m;else return ((b % m) * Bigmod(b,p-1,m)) % m;}
template <typename T> T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
template <typename T> T DIFF(T a,T b) { T d = a-b;if(d<0)return -d;else return d;}
template <typename T> T ABS(T a) {if(a<0)return -a;else return a;}
template <typename T> T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
template <typename T> T euclide(T a,T b,T &x,T &y) {if(a<0){T d=euclide(-a,b,x,y);x=-x;return d;}   if(b<0){T d=euclide(a,-b,x,y);y=-y;return d;}   if(b==0){x=1;y=0;return a;}else{T d=euclide(b,a%b,x,y);T t=x;x=y;y=t-(a/b)*y;return d;}}
template <typename T> void ia (T a[],int n){for (int i=0; i<n; i++) cin >> a[i];}
template <typename T> void pa (T a[],int n){for (int i=0; i<n-1; i++) cout << a[i] << " ";cout << a[n-1] << endl;}
template <typename T> LL isLeft(T a,T b,T c) { return (a.x-b.x)*(b.y-c.y)-(b.x-c.x)*(a.y-b.y); }

int    Set(int N,int pos){ return N=N | (1<<pos);}
int  Reset(int N,int pos){return N= N & ~(1<<pos);}
bool Check(int N,int pos){return (bool)(N & (1<<pos));}
template< class T, class X > inline T   togglebit(T a, X i) { T t=1;return (a^(t<<i)); }

int toInt(string s)  { int sm; stringstream ss(s); ss>>sm; return sm; }
int toLlint(string s) { long long int sm; stringstream ss(s); ss>>sm; return sm;}
int cdigittoint(char ch){return ch-'0';}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
bool isConst(char ch){if (isalpha(ch) && !isVowel(ch)) return true; return false;}

double DEG(double x) { return (180.0*x)/(PI);}
double RAD(double x) { return (x*(double)PI)/(180.0);}

#define VI  vector< int >
#define VII vector< VI >
#define VLL vector< LL >
#define PII pair< int , int >
#define PLL pair< LL , LL >
#define VPI vector< PII >

///         0123456789
#define MX  200007
#define MOD 1000000007
#define INF (1<<30)-1+(1<<30)
#define eps 1e-9

struct Node{
    int sum,lazy;
    Node *l,*r;

    Node(){
        sum = lazy = 0;
        l = r = NULL;
    }
};

VI adj[MX],query[MX];
int st[MX],ed[MX];
int node;
Node* Tree[MX];
Node Nodes[1000007];
int cnt;
int ans[MX];

void Dfs(int u,int p){
    st[u] = ++node;

    for (int i=0;i<adj[u].size();i++){
        int v = adj[u][i];

        if (v != p)     Dfs(v,u);
    }

    ed[u] = node;
}

Node* Propagate(Node *u,int l,int r){
    if (u == NULL)  u = &Nodes[++cnt];

    u->lazy = 1;
    u->sum = (r-l+1);
    u->l = u->r = NULL;
}

Node* Update(Node *idx,int l,int r,int s,int e){
    Node *u = &Nodes[++cnt];

    if (idx != NULL)        *u = *idx;

    if(s == l && e == r)    return Propagate(u,l,r);

    int mid = (l+r)>>1;

    if (u->lazy){
        u->l = Propagate(u->l,l,mid);
        u->r = Propagate(u->r,mid+1,r);
    }

    if (e <= mid)       u->l = Update(u->l,l,mid,s,e);
    else if (s > mid)   u->r = Update(u->r,mid+1,r,s,e);
    else{
        u->l = Update(u->l,l,mid,s,mid);
        u->r = Update(u->r,mid+1,r,mid+1,e);
    }

    u->sum = 0;

    if (u->l != NULL)       u->sum += u->l->sum;
    if (u->r != NULL)       u->sum += u->r->sum;

    return u;
}

void Bfs(int s,int n){
    Tree[0] = NULL;

    queue<int> q;

    q.PS(s);
    q.PS(0);

    while (!q.empty()){
        int u = q.front();q.pop();
        int p = q.front();q.pop();

        Tree[u] = Tree[p];

        for (int i=0;i<query[u].size();i+=2){
            int x = query[u][i];
            int y = query[u][i+1];

            Tree[u] = Update(Tree[u],1,n,x,y);
        }

        ans[u] = (Tree[u]==NULL?0:Tree[u]->sum-1);

        for (int i=0;i<adj[u].size();i++){
            int v = adj[u][i];

            if (v != p){
                q.PS(v);
                q.PS(u);
            }
        }
    }
}

int main(){
    DII(n,m);

    for (int i=1;i<n;i++){
        DII(u,v);

        adj[u].PB(v);
        adj[v].PB(u);
    }

    Dfs(1,0);
    cout << "DFS OK!\n";

    for (int i=1;i<=m;i++){
        DII(u,v);

        query[u].PB(st[v]);
        query[u].PB(ed[v]);
        query[u].PB(st[u]);
        query[u].PB(ed[u]);

        query[v].PB(st[u]);
        query[v].PB(ed[u]);
        query[v].PB(st[v]);
        query[v].PB(ed[v]);
    }

    cout << "QUERY NILAM\n";

    Bfs(1,n);

    cout << cnt << endl;

    for(int i=1;i<=n;i++)       P("%d ",ans[i]);

return 0;
}


/*****************************************************************
 *                   BISMILLAHIR RAHMANIR RAHIM                  *
 *          Raihat Zaman Neloy                                   *
 *          JU-CSE-21                                            *
 *          raihatneloy                                          *
 *****************************************************************/

#include<algorithm>
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<deque>
#include<climits>
#include<complex>

#define S scanf
#define P printf

#define LL long long int
#define ULL unsigned long long int
#define D double

#define Max(a,b)    (a>b?a:b)
#define Min(a,b)    (a<b?a:b)
#define _Max(a,b,c) Max(a,Max(b,c))
#define _Min(a,b,c) Min(a,Min(b,c))
#define SQR(n)      (n*n)
#define PI          2.0*acos(0.0)

#define all(a) a.begin(),a.end()
#define X  first
#define Y  second
#define MP make_pair

#define NL         printf("\n");

#define open       freopen("input.txt","r",stdin)
#define close      freopen ("output.txt","w",stdout)
#define Case(a)    printf("Case %d:",a)
#define caseh(a)   printf("Case #%d: ",a)
#define S1(a)      scanf("%d",&a)
#define S2(a,b)    scanf("%d%d",&a,&b)
#define S3(a,b,c)  scanf("%d%d%d",&a,&b,&c)
#define SL1(a)     scanf("%lld",&a)
#define SL2(a,b)   scanf("%lld%lld",&a,&b)
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define CHR        getchar()
#define PB(x)      push_back(x)
#define pb         push_back
#define PP         pop_back()
#define PF(x)      push_front(x)
#define PPF(x)     pop_front()
#define PS(x)      push(x)
#define sz()       size()
#define UB         upper_bound
#define LB         lower_bound
#define mxe(a,n)   (*max_element(a,a+n))
#define mne(a,n)   (*min_element(a,a+n))
#define SUM(a,n)   (accumulate(a,a+n,0))
#define countbit(x) __builtin_popcount(x)
#define DBG(n)      P("Done %d\n",n);

#define DI(X) int (X);             scanf("%d", &X)
#define DII(X, Y) int X, Y;        scanf("%d%d", &X, &Y)
#define DIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)

#define DILL(X) LL (X); scanf("%lld", &X)

// LOOP
#define repv(i,a) for(int i=0;i<(int)a.size();i++)
#define revv(i,a) for(int i=((int)a.size())-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)

#define FS(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)
#define PR(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++) {  cout << *it << " "; } cout << endl;

#define MEM(a,val) memset(a,val,sizeof(a));
#define SET(a)     memset(a,-1,sizeof a)
#define CLR(a)     memset(a,0,sizeof a)

using namespace std;

template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> T in(){char ch;T n = 0;bool ng = false;while (1){ch = getchar();if (ch == '-'){ng = true;ch = getchar();break;}if (ch>='0' && ch<='9')     break;}while (1){n = n*10 + (ch - '0');ch = getchar();if (ch<'0' || ch>'9')   break;}return (ng?-n:n);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
template <typename T> T Bigmod(T b,T p,T m){ if(p==0) return 1; else if (!(p&1)) return SQR(Bigmod(b,p/2,m)) % m;else return ((b % m) * Bigmod(b,p-1,m)) % m;}
template <typename T> T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
template <typename T> T DIFF(T a,T b) { T d = a-b;if(d<0)return -d;else return d;}
template <typename T> T ABS(T a) {if(a<0)return -a;else return a;}
template <typename T> T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
template <typename T> T euclide(T a,T b,T &x,T &y) {if(a<0){T d=euclide(-a,b,x,y);x=-x;return d;}   if(b<0){T d=euclide(a,-b,x,y);y=-y;return d;}   if(b==0){x=1;y=0;return a;}else{T d=euclide(b,a%b,x,y);T t=x;x=y;y=t-(a/b)*y;return d;}}
template <typename T> void ia (T a[],int n){for (int i=0; i<n; i++) cin >> a[i];}
template <typename T> void pa (T a[],int n){for (int i=0; i<n-1; i++) cout << a[i] << " ";cout << a[n-1] << endl;}
template <typename T> LL isLeft(T a,T b,T c) { return (a.x-b.x)*(b.y-c.y)-(b.x-c.x)*(a.y-b.y); }

int    Set(int N,int pos){ return N=N | (1<<pos);}
int  Reset(int N,int pos){return N= N & ~(1<<pos);}
bool Check(int N,int pos){return (bool)(N & (1<<pos));}
template< class T, class X > inline T   togglebit(T a, X i) { T t=1;return (a^(t<<i)); }

int toInt(string s)  { int sm; stringstream ss(s); ss>>sm; return sm; }
int toLlint(string s) { long long int sm; stringstream ss(s); ss>>sm; return sm;}
int cdigittoint(char ch){return ch-'0';}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
bool isConst(char ch){if (isalpha(ch) && !isVowel(ch)) return true; return false;}

double DEG(double x) { return (180.0*x)/(PI);}
double RAD(double x) { return (x*(double)PI)/(180.0);}

#define VI  vector< int >
#define VII vector< VI >
#define VLL vector< LL >
#define PII pair< int , int >
#define PLL pair< LL , LL >
#define VPI vector< PII >

///         0123456789
#define MX  200007
#define MOD 1000000007
#define INF (1<<30)-1+(1<<30)
#define eps 1e-9

struct Node{
    int sum,lazy;
    Node *l,*r;

    Node(){
        sum = lazy = 0;
        l = r = NULL;
    }
};

VI adj[MX],query[MX];
int st[MX],ed[MX];
int node;
Node* Tree[MX];
Node Nodes[1000007];
int cnt;
int ans[MX];

void Dfs(int u,int p){
    st[u] = ++node;

    for (int i=0;i<adj[u].size();i++){
        int v = adj[u][i];

        if (v != p)     Dfs(v,u);
    }

    ed[u] = node;
}

Node* Propagate(Node *u,int l,int r){
    if (u == NULL)  u = &Nodes[++cnt];

    u->lazy = 1;
    u->sum = (r-l+1);
    u->l = u->r = NULL;
}

Node* Update(Node *idx,int l,int r,int s,int e){
    Node *u = &Nodes[++cnt];

    if (idx != NULL)        *u = *idx;

    if(s == l && e == r)    return Propagate(u,l,r);

    int mid = (l+r)>>1;

    if (u->lazy){
        u->l = Propagate(u->l,l,mid);
        u->r = Propagate(u->r,mid+1,r);
    }

    if (e <= mid)       u->l = Update(u->l,l,mid,s,e);
    else if (s > mid)   u->r = Update(u->r,mid+1,r,s,e);
    else{
        u->l = Update(u->l,l,mid,s,mid);
        u->r = Update(u->r,mid+1,r,mid+1,e);
    }

    u->sum = 0;

    if (u->l != NULL)       u->sum += u->l->sum;
    if (u->r != NULL)       u->sum += u->r->sum;

    return u;
}

void Bfs(int s,int n){
    Tree[0] = NULL;

    queue<int> q;

    q.PS(s);
    q.PS(0);

    while (!q.empty()){
        int u = q.front();q.pop();
        int p = q.front();q.pop();

        Tree[u] = Tree[p];

        for (int i=0;i<query[u].size();i+=2){
            int x = query[u][i];
            int y = query[u][i+1];

            Tree[u] = Update(Tree[u],1,n,x,y);
        }

        ans[u] = (Tree[u]==NULL?0:Tree[u]->sum-1);

        for (int i=0;i<adj[u].size();i++){
            int v = adj[u][i];

            if (v != p){
                q.PS(v);
                q.PS(u);
            }
        }
    }
}

int main(){
    DII(n,m);
    cout << n << endl;

    for (int i=1;i<n;i++){
        DII(u,v);
        cout << u << " " << v << endl;

        adj[u].PB(v);
        adj[v].PB(u);
    }
    cout << m << endl;
    cout << "DFS OK!\n";
    Dfs(1,0);
    cout << "DFS OK!\n";

    for (int i=1;i<=m;i++){
        DII(u,v);

        query[u].PB(st[v]);
        query[u].PB(ed[v]);
        query[u].PB(st[u]);
        query[u].PB(ed[u]);

        query[v].PB(st[u]);
        query[v].PB(ed[u]);
        query[v].PB(st[v]);
        query[v].PB(ed[v]);
    }

    cout << "QUERY NILAM\n";

    Bfs(1,n);

    cout << cnt << endl;

    for(int i=1;i<=n;i++)       P("%d ",ans[i]);

return 0;
}


#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <vector>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long       LL;
typedef pair<int, int>  PII;
typedef pair<LL, LL>    PLL;
typedef vector<int>     VI;
typedef vector<LL>      VL;
typedef vector<PII>     VPII;
typedef vector<VI>      VVI;
typedef vector<VPII>    VVPII;
#define MM(a,x) memset(a,x,sizeof(a));
#define ALL(x)  (x).begin(), (x).end()
#define P(x)	 cerr<<"["#x<<" = "<<(x)<<"]"<<endl;
#define P2(x,y)	 cerr<<"["#x" = "<<(x)<<", "#y" = "<<(y)<<"]"<<endl;
#define P3(x,y,z)cerr<<"["#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<"]"<<endl;
#define PP(x,i)	 cerr<<"["#x<<i<<" = "<<x[i]<<"]"<<endl;
#define TM(a,b)	 cerr<<"["#a" -> "#b": "<<1e3*(b-a)/CLOCKS_PER_SEC<<"ms]\n";
#define UN(v)   sort(ALL(v)), v.resize(unique(ALL(v))-v.begin())
#define mp make_pair
#define pb push_back
#define x first
#define y second
struct _ {_() {ios_base::sync_with_stdio(0);}} _;
template<class A, class B> ostream& operator<<(ostream &o, pair<A, B> t) {o << "(" << t.x << ", " << t.y << ")"; return o;}
template<class T> string tostring(T x, int len = 0, char c = '0') {stringstream ss; ss << x; string r = ss.str(); if(r.length() < len) r = string(len - r.length(), c) + r; return r;}
template<class T> void PV(T a, T b, int n = 0, int w = 0, string s = " ") {int c = 0; while(a != b) {cout << tostring(*a++, w, ' '); if(a != b && (n == 0 || ++c % n)) cout << s; else cout << "\n"; cout.flush();}}
template<class T> inline bool chmin(T &a, T b) {return a > b ? a = b, 1 : 0;}
template<class T> inline bool chmax(T &a, T b) {return a < b ? a = b, 1 : 0;}
const LL linf = 0x3f3f3f3f3f3f3f3fLL;
const int inf = 0x3f3f3f3f;
const int mod = int(1e9) + 7;
const int N = 111111;

int n, m;
VI g[N];
int s[N], e[N], tick;
VI q[N];
int res[N];

struct segment_tree {
	static const int maxn = 4 * N;
	int nonzero[maxn];
	int cover[maxn];

	void add(int L, int R, int c, int l, int r, int x) {
		if(L <= l && r <= R) {
			cover[x] += c;
			if(l == r) nonzero[x] = cover[x] > 0;
			if(cover[x] > 0) {
				nonzero[x] = r - l + 1;
			} else {
				nonzero[x] = nonzero[2 * x] + nonzero[2 * x + 1];
			}
			return;
		}
		int m = (l + r) / 2;
		if(L <= m) add(L, R, c, l, m, 2 * x);
		if(R > m) add(L, R, c, m + 1, r, 2 * x + 1);
		if(cover[x] == 0) nonzero[x] = nonzero[2 * x] + nonzero[2 * x + 1];
		else nonzero[x] = r - l + 1;
	}
} sgt;

void dfs0(int u, int par) {
	s[u] = ++tick;
	for(int v : g[u]) if(v != par) dfs0(v, u);
	e[u] = tick;
}

void dfs1(int u, int par) {
	for(int v : q[u]) sgt.add(s[v], e[v], 1, 1, n, 1);
	res[u] = sgt.nonzero[1];
	for(int v : g[u]) if(v != par) dfs1(v, u);
	for(int v : q[u]) sgt.add(s[v], e[v], -1, 1, n, 1);
}

int main() {
	cin >> n >> m;
	for(int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		g[u].pb(v);
		g[v].pb(u);
	}

	dfs0(1, 0);

	for(int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		q[a].pb(b);
		q[b].pb(a);
		q[a].pb(a);
		q[b].pb(b);
	}

	dfs1(1, 0);

	for(int i = 1; i <= n; i++) cout << max(0, res[i] - 1) << " ";
	cout << endl;

	return 0;
}


#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <vector>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long       LL;
typedef pair<int, int>  PII;
typedef pair<LL, LL>    PLL;
typedef vector<int>     VI;
typedef vector<LL>      VL;
typedef vector<PII>     VPII;
typedef vector<VI>      VVI;
typedef vector<VPII>    VVPII;
#define MM(a,x) memset(a,x,sizeof(a));
#define ALL(x)  (x).begin(), (x).end()
#define P(x)	 cerr<<"["#x<<" = "<<(x)<<"]"<<endl;
#define P2(x,y)	 cerr<<"["#x" = "<<(x)<<", "#y" = "<<(y)<<"]"<<endl;
#define P3(x,y,z)cerr<<"["#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<"]"<<endl;
#define PP(x,i)	 cerr<<"["#x<<i<<" = "<<x[i]<<"]"<<endl;
#define TM(a,b)	 cerr<<"["#a" -> "#b": "<<1e3*(b-a)/CLOCKS_PER_SEC<<"ms]\n";
#define UN(v)   sort(ALL(v)), v.resize(unique(ALL(v))-v.begin())
#define mp make_pair
#define pb push_back
#define x first
#define y second
struct _ {_() {ios_base::sync_with_stdio(0);}} _;
template<class A, class B> ostream& operator<<(ostream &o, pair<A, B> t) {o << "(" << t.x << ", " << t.y << ")"; return o;}
template<class T> string tostring(T x, int len = 0, char c = '0') {stringstream ss; ss << x; string r = ss.str(); if(r.length() < len) r = string(len - r.length(), c) + r; return r;}
template<class T> void PV(T a, T b, int n = 0, int w = 0, string s = " ") {int c = 0; while(a != b) {cout << tostring(*a++, w, ' '); if(a != b && (n == 0 || ++c % n)) cout << s; else cout << "\n"; cout.flush();}}
template<class T> inline bool chmin(T &a, T b) {return a > b ? a = b, 1 : 0;}
template<class T> inline bool chmax(T &a, T b) {return a < b ? a = b, 1 : 0;}
const LL linf = 0x3f3f3f3f3f3f3f3fLL;
const int inf = 0x3f3f3f3f;
const int mod = int(1e9) + 7;
const int N = 111111;

int n, m;
VI g[N];
int s[N], e[N], tick;
VI q[N];
int res[N];

struct segment_tree {
	static const int maxn = 4 * N;
	int nonzero[maxn];
	int cover[maxn];

	void add(int L, int R, int c, int l, int r, int x) {
		if(L <= l && r <= R) {
			cover[x] += c;
			if(l == r) nonzero[x] = cover[x] > 0;
			if(cover[x] > 0) {
				nonzero[x] = r - l + 1;
			} else {
				nonzero[x] = nonzero[2 * x] + nonzero[2 * x + 1];
			}
			return;
		}
		int m = (l + r) / 2;
		if(L <= m) add(L, R, c, l, m, 2 * x);
		if(R > m) add(L, R, c, m + 1, r, 2 * x + 1);
		if(cover[x] == 0) nonzero[x] = nonzero[2 * x] + nonzero[2 * x + 1];
	}
} sgt;

void dfs0(int u, int par) {
	s[u] = ++tick;
	for(int v : g[u]) if(v != par) dfs0(v, u);
	e[u] = tick;
}

void dfs1(int u, int par) {
	for(int v : q[u]) sgt.add(s[v], e[v], 1, 1, n, 1);
	res[u] = sgt.nonzero[1];
	for(int v : g[u]) if(v != par) dfs1(v, u);
	for(int v : q[u]) sgt.add(s[v], e[v], -1, 1, n, 1);
}

int main() {
	cin >> n >> m;
	for(int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		g[u].pb(v);
		g[v].pb(u);
	}

	dfs0(1, 0);

	for(int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		q[a].pb(b);
		q[b].pb(a);
		q[a].pb(a);
		q[b].pb(b);
	}

	dfs1(1, 0);

	for(int i = 1; i <= n; i++) cout << max(0, res[i] - 1) << " ";
	cout << endl;

	return 0;
}


#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <vector>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long       LL;
typedef pair<int, int>  PII;
typedef pair<LL, LL>    PLL;
typedef vector<int>     VI;
typedef vector<LL>      VL;
typedef vector<PII>     VPII;
typedef vector<VI>      VVI;
typedef vector<VPII>    VVPII;
#define MM(a,x) memset(a,x,sizeof(a));
#define ALL(x)  (x).begin(), (x).end()
#define P(x)	 cerr<<"["#x<<" = "<<(x)<<"]"<<endl;
#define P2(x,y)	 cerr<<"["#x" = "<<(x)<<", "#y" = "<<(y)<<"]"<<endl;
#define P3(x,y,z)cerr<<"["#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<"]"<<endl;
#define PP(x,i)	 cerr<<"["#x<<i<<" = "<<x[i]<<"]"<<endl;
#define TM(a,b)	 cerr<<"["#a" -> "#b": "<<1e3*(b-a)/CLOCKS_PER_SEC<<"ms]\n";
#define UN(v)   sort(ALL(v)), v.resize(unique(ALL(v))-v.begin())
#define mp make_pair
#define pb push_back
#define x first
#define y second
struct _ {_() {ios_base::sync_with_stdio(0);}} _;
template<class A, class B> ostream& operator<<(ostream &o, pair<A, B> t) {o << "(" << t.x << ", " << t.y << ")"; return o;}
template<class T> string tostring(T x, int len = 0, char c = '0') {stringstream ss; ss << x; string r = ss.str(); if(r.length() < len) r = string(len - r.length(), c) + r; return r;}
template<class T> void PV(T a, T b, int n = 0, int w = 0, string s = " ") {int c = 0; while(a != b) {cout << tostring(*a++, w, ' '); if(a != b && (n == 0 || ++c % n)) cout << s; else cout << "\n"; cout.flush();}}
template<class T> inline bool chmin(T &a, T b) {return a > b ? a = b, 1 : 0;}
template<class T> inline bool chmax(T &a, T b) {return a < b ? a = b, 1 : 0;}
const LL linf = 0x3f3f3f3f3f3f3f3fLL;
const int inf = 0x3f3f3f3f;
const int mod = int(1e9) + 7;
const int N = 111111;

int n, m;
VI g[N];
int s[N], e[N], tick;
VI q[N];
int res[N];

struct segment_tree {
	static const int maxn = 4 * N;
	int nonzero[N];
	int cover[N];

	void add(int L, int R, int c, int l, int r, int x) {
		if(L <= l && r <= R) {
			cover[x] += c;
			if(l == r) nonzero[x] = cover[x] > 0;
			if(cover[x] > 0) {
				nonzero[x] = r - l + 1;
			} else {
				nonzero[x] = nonzero[2 * x] + nonzero[2 * x + 1];
			}
			return;
		}
		int m = (l + r) / 2;
		if(L <= m) add(L, R, c, l, m, 2 * x);
		if(R > m) add(L, R, c, m + 1, r, 2 * x + 1);
		nonzero[x] = nonzero[2 * x] + nonzero[2 * x + 1];
	}
} sgt;

void dfs0(int u, int par) {
	s[u] = ++tick;
	for(int v : g[u]) if(v != par) dfs0(v, u);
	e[u] = tick;
}

void dfs1(int u, int par) {
	for(int v : q[u]) sgt.add(s[v], e[v], 1, 1, n, 1);
	res[u] = sgt.nonzero[1];
	for(int v : g[u]) if(v != par) dfs1(v, u);
	for(int v : q[u]) sgt.add(s[v], e[v], -1, 1, n, 1);
}

int main() {
	cin >> n >> m;
	for(int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		g[u].pb(v);
		g[v].pb(u);
	}

	dfs0(1, 0);

	for(int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		q[a].pb(b);
		q[b].pb(a);
		q[a].pb(a);
		q[b].pb(b);
	}

	dfs1(1, 0);

	for(int i = 1; i <= n; i++) cout << max(0, res[i] - 1) << " ";
	cout << endl;

	return 0;
}


#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <vector>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long       LL;
typedef pair<int, int>  PII;
typedef pair<LL, LL>    PLL;
typedef vector<int>     VI;
typedef vector<LL>      VL;
typedef vector<PII>     VPII;
typedef vector<VI>      VVI;
typedef vector<VPII>    VVPII;
#define MM(a,x) memset(a,x,sizeof(a));
#define ALL(x)  (x).begin(), (x).end()
#define P(x)	 cerr<<"["#x<<" = "<<(x)<<"]"<<endl;
#define P2(x,y)	 cerr<<"["#x" = "<<(x)<<", "#y" = "<<(y)<<"]"<<endl;
#define P3(x,y,z)cerr<<"["#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<"]"<<endl;
#define PP(x,i)	 cerr<<"["#x<<i<<" = "<<x[i]<<"]"<<endl;
#define TM(a,b)	 cerr<<"["#a" -> "#b": "<<1e3*(b-a)/CLOCKS_PER_SEC<<"ms]\n";
#define UN(v)   sort(ALL(v)), v.resize(unique(ALL(v))-v.begin())
#define mp make_pair
#define pb push_back
#define x first
#define y second
struct _ {_() {ios_base::sync_with_stdio(0);}} _;
template<class A, class B> ostream& operator<<(ostream &o, pair<A, B> t) {o << "(" << t.x << ", " << t.y << ")"; return o;}
template<class T> string tostring(T x, int len = 0, char c = '0') {stringstream ss; ss << x; string r = ss.str(); if(r.length() < len) r = string(len - r.length(), c) + r; return r;}
template<class T> void PV(T a, T b, int n = 0, int w = 0, string s = " ") {int c = 0; while(a != b) {cout << tostring(*a++, w, ' '); if(a != b && (n == 0 || ++c % n)) cout << s; else cout << "\n"; cout.flush();}}
template<class T> inline bool chmin(T &a, T b) {return a > b ? a = b, 1 : 0;}
template<class T> inline bool chmax(T &a, T b) {return a < b ? a = b, 1 : 0;}
const LL linf = 0x3f3f3f3f3f3f3f3fLL;
const int inf = 0x3f3f3f3f;
const int mod = int(1e9) + 7;
const int N = 111111;

int n, m;
VI g[N];
int s[N], e[N], tick;
VI q[N];
int res[N];

struct segment_tree {
	static const int maxn = 4 * N;
	int nonzero[maxn];
	int cover[maxn];

	void add(int L, int R, int c, int l, int r, int x) {
		if(L <= l && r <= R) {
			cover[x] += c;
			if(l == r) nonzero[x] = cover[x] > 0;
			else if(cover[x] > 0) {
				nonzero[x] = r - l + 1;
			} else {
				nonzero[x] = nonzero[2 * x] + nonzero[2 * x + 1];
			}
			return;
		}
		int m = (l + r) / 2;
		if(L <= m) add(L, R, c, l, m, 2 * x);
		if(R > m) add(L, R, c, m + 1, r, 2 * x + 1);
		if(cover[x] == 0) nonzero[x] = nonzero[2 * x] + nonzero[2 * x + 1];
	}
} sgt;

void dfs0(int u, int par) {
	s[u] = ++tick;
	for(int v : g[u]) if(v != par) dfs0(v, u);
	e[u] = tick;
}

void dfs1(int u, int par) {
	for(int v : q[u]) sgt.add(s[v], e[v], 1, 1, n, 1);
	res[u] = sgt.nonzero[1];
	for(int v : g[u]) if(v != par) dfs1(v, u);
	for(int v : q[u]) sgt.add(s[v], e[v], -1, 1, n, 1);
}

int main() {
	cin >> n >> m;
	for(int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		g[u].pb(v);
		g[v].pb(u);
	}

	dfs0(1, 0);

	for(int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		q[a].pb(b);
		q[b].pb(a);
		q[a].pb(a);
		q[b].pb(b);
	}

	dfs1(1, 0);

	for(int i = 1; i <= n; i++) cout << max(0, res[i] - 1) << " ";
	cout << endl;

	return 0;
}


#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <vector>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long       LL;
typedef pair<int, int>  PII;
typedef pair<LL, LL>    PLL;
typedef vector<int>     VI;
typedef vector<LL>      VL;
typedef vector<PII>     VPII;
typedef vector<VI>      VVI;
typedef vector<VPII>    VVPII;
#define MM(a,x) memset(a,x,sizeof(a));
#define ALL(x)  (x).begin(), (x).end()
#define P(x)	 cerr<<"["#x<<" = "<<(x)<<"]"<<endl;
#define P2(x,y)	 cerr<<"["#x" = "<<(x)<<", "#y" = "<<(y)<<"]"<<endl;
#define P3(x,y,z)cerr<<"["#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<"]"<<endl;
#define PP(x,i)	 cerr<<"["#x<<i<<" = "<<x[i]<<"]"<<endl;
#define TM(a,b)	 cerr<<"["#a" -> "#b": "<<1e3*(b-a)/CLOCKS_PER_SEC<<"ms]\n";
#define UN(v)   sort(ALL(v)), v.resize(unique(ALL(v))-v.begin())
#define mp make_pair
#define pb push_back
#define x first
#define y second
struct _ {_() {ios_base::sync_with_stdio(0);}} _;
template<class A, class B> ostream& operator<<(ostream &o, pair<A, B> t) {o << "(" << t.x << ", " << t.y << ")"; return o;}
template<class T> string tostring(T x, int len = 0, char c = '0') {stringstream ss; ss << x; string r = ss.str(); if(r.length() < len) r = string(len - r.length(), c) + r; return r;}
template<class T> void PV(T a, T b, int n = 0, int w = 0, string s = " ") {int c = 0; while(a != b) {cout << tostring(*a++, w, ' '); if(a != b && (n == 0 || ++c % n)) cout << s; else cout << "\n"; cout.flush();}}
template<class T> inline bool chmin(T &a, T b) {return a > b ? a = b, 1 : 0;}
template<class T> inline bool chmax(T &a, T b) {return a < b ? a = b, 1 : 0;}
const LL linf = 0x3f3f3f3f3f3f3f3fLL;
const int inf = 0x3f3f3f3f;
const int mod = int(1e9) + 7;
const int N = 111111;

int n, m;
VI g[N];
int s[N], e[N], tick;
VI q[N];
int res[N];

struct segment_tree {
	static const int maxn = 4 * N;
	int nonzero[N];
	int cover[N];

	void add(int L, int R, int c, int l, int r, int x) {
		if(L <= l && r <= R) {
			cover[x] += c;
			if(l == r) nonzero[x] = cover[x] > 0;
			if(cover[x] > 0) {
				nonzero[x] = r - l + 1;
			} else {
				nonzero[x] = nonzero[2 * x] + nonzero[2 * x + 1];
			}
			return;
		}
		int m = (l + r) / 2;
		if(L <= m) add(L, R, c, l, m, 2 * x);
		if(R > m) add(L, R, c, m + 1, r, 2 * x + 1);
		if(cover[x] == 0) nonzero[x] = nonzero[2 * x] + nonzero[2 * x + 1];
	}
} sgt;

void dfs0(int u, int par) {
	s[u] = ++tick;
	for(int v : g[u]) if(v != par) dfs0(v, u);
	e[u] = tick;
}

void dfs1(int u, int par) {
	for(int v : q[u]) sgt.add(s[v], e[v], 1, 1, n, 1);
	res[u] = sgt.nonzero[1];
	for(int v : g[u]) if(v != par) dfs1(v, u);
	for(int v : q[u]) sgt.add(s[v], e[v], -1, 1, n, 1);
}

int main() {
	cin >> n >> m;
	for(int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		g[u].pb(v);
		g[v].pb(u);
	}

	dfs0(1, 0);

	for(int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		q[a].pb(b);
		q[b].pb(a);
		q[a].pb(a);
		q[b].pb(b);
	}

	dfs1(1, 0);

	for(int i = 1; i <= n; i++) cout << max(0, res[i] - 1) << " ";
	cout << endl;

	return 0;
}