#include<bits/stdc++.h>
typedef int IT;
typedef long long LL;
typedef __int128 int128;
typedef double DB;
typedef long double LDB;
#define pb push_back
#define fst first
#define sec second
#define psh push
#define mkp make_pair
#define PII pair<IT,IT>
#define PLI pair<LL,IT>
#define lowbit(x) ((x)&(-x))
using namespace std;
const int N=5e4+10,ES=(N<<1);
const int INF=0x3f3f3f3f;
int n,k;
int ecnt,head[N],nxt[ES],to[ES];
void add(int x,int y){
nxt[++ecnt]=head[x];
head[x]=ecnt;
to[ecnt]=y;
return;
}
struct node{
int sum;
int tag;
}t[N<<2];
void pushup(int rt){
t[rt].sum=t[rt<<1].sum+t[rt<<1|1].sum;
return;
}
void downtag(int rt,int l,int r,int v){
t[rt].sum+=(r-l+1)*v;
t[rt].tag+=v;
return;
}
void pushdown(int rt,int l,int r){
if(t[rt].tag){
int mid=(l+r)>>1;
downtag(rt<<1,l,mid,t[rt].tag);
downtag(rt<<1|1,mid+1,r,t[rt].tag);
t[rt].tag=0;
}
}
void build(int rt,int l,int r){
if(l==r){
t[rt].sum=0;
return;
}
int mid=(l+r)>>1;
build(rt<<1,l,mid);
build(rt<<1|1,mid+1,r);
pushup(rt);
return;
}
void modify(int rt,int l,int r,int ml,int mr,int v){
if(r<ml||mr<l) return;
if(ml<=l&&r<=mr){
downtag(rt,l,r,v);
return;
}
pushdown(rt,l,r);
int mid=(l+r)>>1;
modify(rt<<1,l,mid,ml,mr,v);
modify(rt<<1|1,mid+1,r,ml,mr,v);
pushup(rt);
return;
}
int querymx(int rt,int l,int r,int ql,int qr){
if(r<ql||qr<l) return -INF;
if(ql<=l&&r<=qr) return t[rt].sum;
pushdown(rt,l,r);
int mid=(l+r)>>1;
return max(querymx(rt<<1,l,mid,ql,qr),
querymx(rt<<1|1,mid+1,r,ql,qr));
}
int dep[N],siz[N],son[N],fa[N];
void dfs1(int x,int fth){
dep[x]=dep[fth]+1;
siz[x]=1;
fa[x]=fth;
for(int i=head[x];i;i=nxt[i]){
int y=to[i];
if(y==fth) continue;
dfs1(y,x);
siz[x]+=siz[y];
if(siz[y]>siz[son[x]])
son[x]=y;
}
}
int top[N];
int id[N],idx;
void dfs2(int x,int ntop){
top[x]=ntop;
id[x]=++idx;
if(!son[x]) return;
dfs2(son[x],ntop);
for(int i=head[x];i;i=nxt[i]){
int y=to[i];
if(y!=fa[x]&&y!=son[x])
dfs2(y,y);
}
}
void SP_modify(int x,int y){
while(top[x]!=top[y]){
if(dep[top[x]]<dep[top[y]]) swap(x,y);
modify(1,1,n,id[top[x]],id[x],1);
x=fa[top[x]];
}
if(dep[x]>dep[y]) swap(x,y);
modify(1,1,n,id[x],id[y],1);
return;
}
int main(){
scanf("%d%d",&n,&k);
for(int i=1;i<n;i++){
int x,y;
scanf("%d%d",&x,&y);
add(x,y),add(y,x);
}
dfs1(1,0);
dfs2(1,1);
while(k--){
int s,t;
scanf("%d%d",&s,&t);
SP_modify(s,t);
}
printf("%d\n",t[1].sum);
for(int i=1;i<=n<<2;i++) printf("%d ",t[1].sum);putchar('\n');
return 0;
}