#include <bits/stdc++.h>
using namespace std;
const int N = 5e4+5;
typedef long long ll;
int n,m;
struct E {
int nxt,to;
}e[N<<1];
int head[N],tot;
void add(int x,int y) {
e[++tot].to = y;e[tot].nxt = head[x];head[x] = tot;
}
ll tr[N<<2];
int lazy[N<<2];
ll decn[N];
ll adding,times;
void build(int p,int l,int r) {
tr[p] = 0;
lazy[p] = 0;
if (l==r)return;
int mid = (l+r)>>1;
build(p<<1,l,mid);
build(p<<1|1,mid+1,r);
}
void Push_Down(int p,int l,int r) {
if (l==r||!lazy[p])return;
int mid = (l+r)>>1;
tr[p<<1] += (ll)(mid-l+1)*lazy[p];
tr[p<<1|1] += (ll)(r-mid)*lazy[p];
lazy[p<<1]+=lazy[p];
lazy[p<<1|1]+=lazy[p];
lazy[p] = 0;
}
void Update(int p,int l,int r,int a,int b,int c) {
Push_Down(p,l,r);
if (l>=a && r<=b) {
tr[p] += (ll)(r-l+1)*c;
lazy[p] += c;
return;
}
int mid = (l+r)>>1;
if (a <= mid)Update(p<<1,l,mid,a,b,c);
if (b > mid)Update(p<<1|1,mid+1,r,a,b,c);
tr[p] = tr[p<<1]+tr[p<<1|1];
}
ll Getans(int p,int l,int r,int a,int b) {
Push_Down(p,l,r);
if (l>=a && r<=b) return tr[p];
ll ans = 0;
int mid = (l+r)>>1;
if (a <= mid)ans+=Getans(p<<1,l,mid,a,b);
if (b > mid)ans+=Getans(p<<1|1,mid+1,r,a,b);
return ans;
}
int size[N],son[N],w[N],top[N],fa[N],cnt,id[N],dpt[N];
void dfs1(int x,int f) {
fa[x] = f;
size[x] = 1;
dpt[x] = dpt[f]+1;
son[x] = 0;
for (int i = head[x];i;i=e[i].nxt) {
if (e[i].to == f)continue;
dfs1(e[i].to,x);
size[x]+=size[e[i].to];
if (size[e[i].to] > size[son[x]])son[x] = e[i].to;
}
}
void dfs2(int x,int tp) {
top[x] = tp;
w[x] = ++cnt;
id[cnt] = x;
if (son[x])dfs2(son[x],tp);
for (int i = head[x];i;i=e[i].nxt)
if (e[i].to!=son[x] && e[i].to!=fa[x])
dfs2(e[i].to,e[i].to);
}
void update(int x,int y,int z)
{
while (top[x]!=top[y])
{
if (dpt[top[x]]<dpt[top[y]])swap(x,y);
Update(1,1,n,w[top[x]],w[x],z);
x = fa[top[x]];
}
if (dpt[x]<dpt[y])swap(x,y);
Update(1,1,n,w[y],w[x],z);
}
ll getans(int x,int y)
{
ll ans = 0;
while (top[x]!=top[y])
{
if (dpt[top[x]]<dpt[top[y]])swap(x,y);
ans+=Getans(1,1,n,w[top[x]],w[x]);
x = fa[top[x]];
}
if (dpt[x]<dpt[y])swap(x,y);
ans+=Getans(1,1,n,w[y],w[x]);
return ans;
}
ll getFx(int x) {
ll ans = decn[x]-(ll)times*dpt[x];
ans = ans+adding;
ans = ans+getans(1,x);
return ans;
}
void init() {
memset(head,0,sizeof(head));
memset(decn,0,sizeof(decn));
tot = cnt = 0;
adding = times = 0;
}
int main()
{
int cas;
scanf("%d",&cas);
while(cas--) {
init();
scanf("%d%d",&n,&m);
int x,y;
for (int i = 1;i<n;i++) {
scanf("%d%d",&x,&y);
add(x,y);add(y,x);
}
build(1,1,n);
dfs1(1,0);
dfs2(1,1);
while (m--) {
int opt;
scanf("%d",&opt);
if (opt == 1) {
scanf("%d%d",&x,&y);
adding += y-dpt[x];
times++;
update(1,x,2);
} else if(opt == 2) {
scanf("%d",&x);
ll tmp = getFx(x);
if (tmp > 0) decn[x]-=tmp;
} else {
scanf("%d",&x);
printf("%lld\n",getFx(x));
}
}
}
}