#include <set>
#include <map>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define debug puts("here")
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define foreach(i,vec) for(unsigned i=0;i<vec.size();i++)
#define pb push_back
#define RD(n) scanf("%d",&n)
#define RD2(x,y) scanf("%d%d",&x,&y)
#define RD3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define RD4(x,y,z,w) scanf("%d%d%d%d",&x,&y,&z,&w)
#define All(vec) vec.begin(),vec.end()
#define MP make_pair
#define PII pair<int,int>
#define PQ priority_queue
#define cmax(x,y) x = max(x,y)
#define cmin(x,y) x = min(x,y)
#define Clear(x) memset(x,0,sizeof(x))
/*
#pragma comment(linker, "/STACK:1024000000,1024000000")
int size = 256 << 20; // 256MB
char *p = (char*)malloc(size) + size;
__asm__("movl %0, %%esp\n" :: "r"(p) );
*/
/******** program ********************/
char op,s[12];
int tp;
inline void Int(int &x){
while( !isdigit(op=getchar()) );
x = op-'0';
while( isdigit(op=getchar()) )
x = x*10+op-'0';
}
inline void LL(ll &x){
while( !isdigit(op=getchar()) );
x = op-'0';
while( isdigit(op=getchar()) )
x = x*10+op-'0';
}
inline void Out(ll x){
s[0] = '0';
tp = 0;
while(x){
s[tp++] = x%10+'0';
x /= 10;
}
for(int i=tp-1;i>=0;i--)
putchar(s[i]);
puts("");
}
const int MAXN = 200005;
const int LOG = 17;
const ll INF = 1e15;
int p[MAXN][18];
int son[MAXN],sz[MAXN],dep[MAXN],fa[MAXN],top[MAXN],tim;
bool use[MAXN];
int st[MAXN],ed[MAXN];
int po[MAXN],tol;
ll def[MAXN],val[MAXN];
int n,m;
struct Edge{
int y,next;
}edge[MAXN<<1];
inline void add(int x,int y){
edge[++tol].y = y;
edge[tol].next = po[x];
po[x] = tol;
}
// 树链剖分
void dfsFind(int x,int pa,int depth){
p[x][0] = pa;
rep1(i,LOG)
p[x][i] = p[ p[x][i-1] ][i-1];
son[x] = 0;
sz[x] = 1;
dep[x] = depth;
fa[x] = pa;
for(int i=po[x];i;i=edge[i].next){
int y = edge[i].y;
if(y==pa)continue;
dfsFind(y,x,depth+1);
sz[x] += sz[y];
if(sz[y]>sz[son[x]])
son[x] = y;
}
}
void dfsCon(int x,int pa){
use[x] = true;
top[x] = pa;
st[x] = ++ tim; // 记录进入时的时间戳
if(son[x])dfsCon(son[x],pa);
for(int i=po[x];i;i=edge[i].next){
int y = edge[i].y;
if(!use[y])dfsCon(y,y);
}
ed[x] = ++ tim; // 记录出去时的时间戳
}
// 倍增部分
inline int kth(int x,int k){ // 第k个祖先
rep(i,LOG)
if( k>>i & 1 )
x = p[x][i];
return x;
}
inline int lca(int x,int y){
if(dep[x]>dep[y])swap(x,y);
if(dep[x]<dep[y]){
int del = dep[y]-dep[x];
rep(i,LOG)
if( del>>i & 1 )
y = p[y][i];
}
if(x!=y){
for(int i=LOG-1;i>=0;i--)
if(p[x][i]!=p[y][i])
x = p[x][i] , y = p[y][i];
x = p[x][0] , y = p[y][0];
}
return x;
}
// 线段树部分
struct segTree{
int l,r;
ll mx,lz;
inline int mid(){
return (l+r)>>1;
}
void out(){
cout<<l<<" "<<r<<" "<<mx<<" "<<lz<<endl;
}
}tree[MAXN<<2];
inline void push(int rt){
if(tree[rt].lz){
tree[rt].mx = tree[rt].lz;
tree[rt<<1].lz = tree[rt].lz;
tree[rt<<1].mx = tree[rt].lz;
tree[rt<<1|1].lz = tree[rt].lz;
tree[rt<<1|1].mx = tree[rt].lz;
tree[rt].lz = 0;
}
}
inline void update(segTree &now,segTree l,segTree r){
if( ~l.mx ){
if(~r.mx)now.mx = min(l.mx,r.mx);
else now.mx = l.mx;
}else if(~r.mx)now.mx = r.mx;
else now.mx = INF;
}
void build(int l,int r,int rt){
tree[rt].l = l;
tree[rt].r = r;
tree[rt].lz = 0;
tree[rt].mx = INF;
if(l==r)return;
int mid = tree[rt].mid();
build(l,mid,rt<<1);
build(mid+1,r,rt<<1|1);
//update(tree[rt],tree[rt<<1],tree[rt<<1|1]);
}
void modify(int l,int r,ll c,int rt){
if(l<=tree[rt].l&&tree[rt].r<=r){
tree[rt].lz = tree[rt].mx = c;
return;
}
push(rt);
int mid = tree[rt].mid();
if(r<=mid)modify(l,r,c,rt<<1);
else if(l>mid)modify(l,r,c,rt<<1|1);
else{
modify(l,r,c,rt<<1);
modify(l,r,c,rt<<1|1);
}
update(tree[rt],tree[rt<<1],tree[rt<<1|1]);
}
ll ask(int l,int r,int rt){
if(l<=tree[rt].l&&tree[rt].r<=r){
if(~tree[rt].mx)
return tree[rt].mx;
return INF;
}
push(rt);
int mid = tree[rt].mid();
ll ans;
if(r<=mid)ans = ask(l,r,rt<<1);
else if(l>mid)ans = ask(l,r,rt<<1|1);
else
ans = min(ask(l,r,rt<<1),ask(l,r,rt<<1|1));
update(tree[rt],tree[rt<<1],tree[rt<<1|1]);
return ans;
}
// 修改时修改的节点均为进入节点时的时间戳
inline void modify(int x,int y,int w){
while(top[x]!=top[y]){
if(dep[top[x]]<dep[top[y]])
swap(x,y);
modify( st[top[x]],st[x],w,1 );
x = fa[top[x]];
}
if(dep[x]>dep[y])swap(x,y);
modify(st[x],st[y],w,1);
}
int root;
inline ll ask(int x){
if(x==root)return ask(1,n*2,1);
int ca = lca(x,root);
if(ca!=x)return ask(st[x],ed[x],1);
int y; // 根最靠近x的祖先
if(fa[root]==x)y = root;
else y = kth(root,dep[root]-dep[x]-1);
ll ans = INF; // 去掉某个区间就是询问的区间
if(1<=st[y]-1)ans = min(ans,ask(1,st[y]-1,1));
if(2*n>=ed[y]+1)ans = min(ans,ask(ed[y]+1,2*n,1));
return ans;
}
int main(){
#ifndef ONLINE_JUDGE
freopen("sum.in","r",stdin);
//freopen("sum.out","w",stdout);
#endif
int x,y,op;
ll w;
while(~RD2(n,m)){
Clear(po);
tol = 0;
REP(i,2,n){
Int(x);Int(y);
add(x,y);
add(y,x);
}
rep1(i,n)
LL(def[i]);
Int(root);
// 树链剖分
dfsFind(1,1,1);
Clear(use);
tim = 0;
dfsCon(1,1);
// 建树
build(1,2*n,1);
rep1(i,n)
modify(st[i],st[i],def[i],1);
rep1(i,n)
modify(ed[i],ed[i],-1,1); // 出去时的时间戳
while(m--){
Int(op);
if(op==1)Int(root);
else if(op==2){
Int(x);Int(y);LL(w);
modify(x,y,w);
}else{
Int(x);
Out(ask(x));
}
}
}
return 0;
}