#include<bits/stdc++.h>
#define ls k<<1
#define rs k<<1|1
#define lson ls,l,mid
#define rson rs,mid+1,r
#define ulson ls,l,r,w
#define urson rs,l,r,w
#define qlson ls,l,r
#define qrson rs,l,r
#define mid ((tree[k].l+tree[k].r)>>1)
#define l(k) (tree[k].r-tree[k].l+1)
#define int long long
using namespace std;
int n,a[100005],cnt,id[100005],dep[100005],siz[100005],son[100005],top[100005],fa[100005],mp[100005];
pair<int,int> edge[100005];
struct node{
int l,r,maxn,lazy,lazy_cover;
}tree[400005];
vector<pair<int,int> > v[100005];
void push_down(int k){
if(tree[k].lazy_cover){
tree[ls].maxn=tree[rs].maxn=tree[k].lazy_cover;
tree[ls].lazy_cover=tree[k].lazy_cover;
tree[rs].lazy_cover=tree[k].lazy_cover;
tree[ls].lazy=tree[rs].lazy=0;
tree[k].lazy_cover=0;
}
if(tree[k].lazy){
tree[ls].maxn+=tree[k].lazy;
tree[rs].maxn+=tree[k].lazy;
tree[ls].lazy+=tree[k].lazy;
tree[rs].lazy+=tree[k].lazy;
tree[k].lazy=0;
}
}
void push_up(int k){
tree[k].maxn=max(tree[ls].maxn,tree[rs].maxn);
}
void build(int k,int l,int r){
tree[k].l=l;
tree[k].r=r;
if(l==r){
tree[k].maxn=mp[l];
return ;
}
build(lson);
build(rson);
push_up(k);
}
void update(int k,int l,int r,int w){
if(tree[k].l>=l&&tree[k].r<=r){
tree[k].maxn+=w;
tree[k].lazy+=w;
return ;
}
push_down(k);
if(l<=mid){
update(ulson);
}
if(r>mid){
update(urson);
}
push_up(k);
}
void update_cover(int k,int l,int r,int w){
if(tree[k].l>=l&&tree[k].r<=r){
tree[k].maxn=w;
tree[k].lazy_cover=w;
tree[k].lazy=0;
return ;
}
push_down(k);
if(l<=mid){
update(ulson);
}
if(r>mid){
update(urson);
}
push_up(k);
}
int query(int k,int l,int r){
if(tree[k].l>=l&&tree[k].r<=r){
return tree[k].maxn;
}
push_down(k);
int ans=INT_MIN;
if(l<=mid){
ans=max(ans,query(qlson));
}
if(r>mid){
ans=max(ans,query(qrson));
}
return ans;
}
void update_lj(int x,int y,int w){
while(top[x]!=top[y]){
if(dep[top[x]]<dep[top[y]]){
swap(x,y);
}
update(1,id[top[x]],id[x],w);
x=fa[top[x]];
}
if(dep[x]<dep[y]){
swap(x,y);
}
update(1,id[y],id[x],w);
}
void update_lj_cover(int x,int y,int w){
while(top[x]!=top[y]){
if(dep[top[x]]<dep[top[y]]){
swap(x,y);
}
update_cover(1,id[top[x]],id[x],w);
x=fa[top[x]];
}
if(dep[x]<dep[y]){
swap(x,y);
}
update_cover(1,id[y],id[x],w);
}
int query_lj(int x,int y){
int ans=INT_MIN;
while(top[x]!=top[y]){
if(dep[top[x]]<dep[top[y]]){
swap(x,y);
}
ans=max(ans,query(1,id[top[x]],id[x]));
x=fa[top[x]];
}
if(dep[x]<dep[y]){
swap(x,y);
}
return max(ans,query(1,id[y],id[x]));
}
void dfs1(int x,int father){
siz[x]=1;
int maxn=INT_MIN;
for(int i=0;i<v[x].size();i++){
int y=v[x][i].first;
if(y!=father){
dep[y]=dep[x]+1;
fa[y]=x;
a[y]=v[x][i].second;
dfs1(y,x);
siz[x]+=siz[y];
if(siz[y]>maxn){
son[x]=y;
maxn=siz[y];
}
}
}
}
void dfs2(int x,int tp,int father){
id[x]=++cnt;
mp[cnt]=a[x];
top[x]=tp;
if(son[x]){
dfs2(son[x],tp,x);
}
for(int i=0;i<v[x].size();i++){
int y=v[x][i].first;
if(y!=father&&y!=son[x]){
dfs2(y,y,x);
}
}
}
signed main(){
cin>>n;
for(int i=1;i<n;i++){
int x,y,w;
cin>>x>>y>>w;
edge[i]={x,y};
v[x].push_back({y,w});
v[y].push_back({x,w});
}
dfs1(1,-1);
dfs2(1,1,-1);
build(1,1,n);
while(1){
string l;
cin>>l;
if(l=="Stop"){
break;
}
if(l=="Change"){
int k,w;
cin>>k>>w;
update_cover(1,id[edge[k].first],id[edge[k].second],w);
}else if(l=="Cover"){
int u,v,w;
cin>>u>>v>>w;
update_lj_cover(u,v,w);
}else if(l=="Add"){
int u,v,w;
cin>>u>>v>>w;
update_lj(u,v,w);
}else{
int u,v;
cin>>u>>v;
cout<<query_lj(u,v)<<"\n";
}
}
return 0;
}