#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;
const ll range=100005;
vector<ll> tree[range];
ll par[range],st[4*range],tin[range],depth[range],child[range],chain[range],head[range];
ll timer=0,c=0,n;
void dfs(ll u,ll p,ll d)
{
depth[u]=d;
child[u]=1;
par[u]=p;
for(ll v:tree[u])
{
if(v==p)
continue;
dfs(v,u,d+1);
//par[v]=u;
child[u]+=child[v];
}
}
void hld(ll u,ll p)
{
if(head[c]==-1)
head[c]=u;
chain[u]=c;
tin[u]=++timer;
ll special=-1;
for(ll v:tree[u])
{
if(v==p)
continue;
if(special==-1||child[special]<child[v])
special=v;
}
if(special!=-1)
hld(special,u);
for(ll v:tree[u])
{
if(v==p||v==special)
continue;
c++;
hld(v,u);
}
}
ll lca(ll u,ll v)
{
while(head[chain[u]]!=head[chain[v]]){
if(depth[head[chain[u]]]<depth[head[chain[v]]]) v=par[head[chain[v]]];
else u=par[head[chain[u]]];
}
return depth[u]>depth[v]? v:u;
}
/*
ll lca(ll u,ll v,vector<bool> vis)
{
if(depth[u]<depth[v])
swap(u,v);
while(u!=-1)
{
vis[u]=1;
u=par[u];
}
while(1)
{
if(vis[v])
return v;
v=par[v];
}
return 1;
}
*/
ll query(ll ss,ll se,ll si,ll l,ll r)
{
if(l<=ss&&r>=se)
return st[si];
if(l>se||r<ss)
return 0;
ll mid=(ss+se)>>1;
return max(query(ss,mid,si+si,l,r),query(mid+1,se,si+si+1,l,r));
}
ll crawl(ll u,ll v)
{
ll ans=0;
while(1)
{
if(chain[u]==chain[v])
{
return max(ans,query(1,n,1,tin[v],tin[u]));
}
ans=max(ans,query(1,n,1,tin[head[chain[u]]],tin[u]));
u=par[head[chain[u]]];
}
return ans;
}
ll ans(ll u,ll v)
{
ll ans=lca(u,v);
return max(crawl(u,ans),crawl(v,ans));
}
void update(ll ss,ll se,ll si,ll i,ll val)
{
if(i>se||i<ss)
return ;
if(se==ss && ss==i) {st[si]+=val;return;}
ll mid=(ss+se)>>1;
update(ss,mid,2*si,i,val);
update(mid+1,se,2*si+1,i,val);
st[si]=max(st[2*si],st[2*si+1]);
//st[si]=max(update(ss,mid,si+si,i,val),update(mid+1,se,si+si+1,i,val));
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll t=1;
//cin>>t;
while(t--){
ll i,u,v,q;
cin>>n;
fr(i,0,n-1)
{
cin>>u>>v;
tree[u].pb(v);
tree[v].pb(u);
//par[i+1]=head[i+1]=-1;
}
//head[1]=-1;
ms(head,-1);
ms(st,0);
dfs(1,-1,0);
//par[1]=-1;
hld(1,1);
cin>>q;
vector<bool> vis(range,0);
while(q--)
{
char g;
cin>>g>>u>>v;
if(g=='I')
update(1,n,1,tin[u],v);
else
cout<<ans(u,v)<<"\n";
// fr(i,0,2*timer)
// cout<<st[i]<<" ";
// cout<<"\n";
}
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBsbCBsb25nIGxvbmcKI2RlZmluZSBtb2QgMTAwMDAwMDAwNwojZGVmaW5lIHBiIHB1c2hfYmFjawojZGVmaW5lIGZpIGZpcnN0CiNkZWZpbmUgc2Ugc2Vjb25kCiNkZWZpbmUgZnIoaSxzLGUpIGZvcihpPXM7aTxlO2krKykKI2RlZmluZSBtcyhhcnIsdmFsKSBtZW1zZXQoYXJyLHZhbCxzaXplb2YoYXJyKSkKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKY29uc3QgbGwgcmFuZ2U9MTAwMDA1Owp2ZWN0b3I8bGw+IHRyZWVbcmFuZ2VdOwpsbCBwYXJbcmFuZ2VdLHN0WzQqcmFuZ2VdLHRpbltyYW5nZV0sZGVwdGhbcmFuZ2VdLGNoaWxkW3JhbmdlXSxjaGFpbltyYW5nZV0saGVhZFtyYW5nZV07CmxsIHRpbWVyPTAsYz0wLG47CnZvaWQgZGZzKGxsIHUsbGwgcCxsbCBkKQp7CiAgICBkZXB0aFt1XT1kOwogICAgY2hpbGRbdV09MTsKICAgIHBhclt1XT1wOwogICAgZm9yKGxsIHY6dHJlZVt1XSkKICAgIHsKICAgICAgICBpZih2PT1wKQogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICBkZnModix1LGQrMSk7CiAgICAgICAgLy9wYXJbdl09dTsKICAgICAgICBjaGlsZFt1XSs9Y2hpbGRbdl07CiAgICB9Cn0Kdm9pZCBobGQobGwgdSxsbCBwKQp7CiAgICBpZihoZWFkW2NdPT0tMSkKICAgICAgICBoZWFkW2NdPXU7CiAgICBjaGFpblt1XT1jOwogICAgdGluW3VdPSsrdGltZXI7CiAgICBsbCBzcGVjaWFsPS0xOwogICAgZm9yKGxsIHY6dHJlZVt1XSkKICAgIHsKICAgICAgICBpZih2PT1wKQogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICBpZihzcGVjaWFsPT0tMXx8Y2hpbGRbc3BlY2lhbF08Y2hpbGRbdl0pCiAgICAgICAgICAgIHNwZWNpYWw9djsKICAgIH0KICAgIGlmKHNwZWNpYWwhPS0xKQogICAgICAgIGhsZChzcGVjaWFsLHUpOwogICAgZm9yKGxsIHY6dHJlZVt1XSkKICAgIHsKICAgICAgICBpZih2PT1wfHx2PT1zcGVjaWFsKQogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICBjKys7CiAgICAgICAgaGxkKHYsdSk7CiAgICB9Cn0KbGwgbGNhKGxsIHUsbGwgdikKewogICAgd2hpbGUoaGVhZFtjaGFpblt1XV0hPWhlYWRbY2hhaW5bdl1dKXsKICAgICAgaWYoZGVwdGhbaGVhZFtjaGFpblt1XV1dPGRlcHRoW2hlYWRbY2hhaW5bdl1dXSkgdj1wYXJbaGVhZFtjaGFpblt2XV1dOwogICAgICBlbHNlIHU9cGFyW2hlYWRbY2hhaW5bdV1dXTsKICAgIH0KICAgIHJldHVybiBkZXB0aFt1XT5kZXB0aFt2XT8gdjp1Owp9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dGUobGwgc3MsbGwgc2UsbGwgc2ksbGwgaSxsbCB2YWwpCnsKICAgIGlmKGk+c2V8fGk8c3MpCiAgICAgICAgcmV0dXJuIDsKICAgIGlmKHNlPT1zcyAmJiBzcz09aSkge3N0W3NpXSs9dmFsO3JldHVybjt9CiAgICBsbCBtaWQ9KHNzK3NlKT4+MTsKICAgIHVwZGF0ZShzcyxtaWQsMipzaSxpLHZhbCk7CiAgICB1cGRhdGUobWlkKzEsc2UsMipzaSsxLGksdmFsKTsKICAgIHN0W3NpXT1tYXgoc3RbMipzaV0sc3RbMipzaSsxXSk7CiAgICAvL3N0W3NpXT1tYXgodXBkYXRlKHNzLG1pZCxzaStzaSxpLHZhbCksdXBkYXRlKG1pZCsxLHNlLHNpK3NpKzEsaSx2YWwpKTsKfQppbnQgbWFpbigpewogICAgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7CiAgICBjaW4udGllKDApOwogICAgY291dC50aWUoMCk7CiAgbGwgdD0xOwogIC8vY2luPj50OwogICAgd2hpbGUodC0tKXsKICAgICAgICAgICAgbGwgaSx1LHYscTsKICAgICAgICAgICAgY2luPj5uOwogICAgICAgICAgICBmcihpLDAsbi0xKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBjaW4+PnU+PnY7CiAgICAgICAgICAgICAgICB0cmVlW3VdLnBiKHYpOwogICAgICAgICAgICAgICAgdHJlZVt2XS5wYih1KTsKICAgICAgICAgICAgICAgIC8vcGFyW2krMV09aGVhZFtpKzFdPS0xOwogICAgICAgICAgICB9CiAgICAgICAgICAgIC8vaGVhZFsxXT0tMTsKICAgICAgICAgICAgbXMoaGVhZCwtMSk7CiAgICAgICAgICAgIG1zKHN0LDApOwogICAgICAgICAgICBkZnMoMSwtMSwwKTsKICAgICAgICAgICAgLy9wYXJbMV09LTE7CiAgICAgICAgICAgIGhsZCgxLDEpOwogICAgICAgICAgICBjaW4+PnE7CiAgICAgICAgICAgIHZlY3Rvcjxib29sPiB2aXMocmFuZ2UsMCk7CiAgICAgICAgICAgIHdoaWxlKHEtLSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgY2hhciBnOwogICAgICAgICAgICAgICAgY2luPj5nPj51Pj52OwogICAgICAgICAgICAgICAgaWYoZz09J0knKQogICAgICAgICAgICAgICAgICAgIHVwZGF0ZSgxLG4sMSx0aW5bdV0sdik7CiAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgY291dDw8YW5zKHUsdik8PCJcbiI7Ci8vCWZyKGksMCwyKnRpbWVyKQovLwljb3V0PDxzdFtpXTw8IiAiOwovLwljb3V0PDwiXG4iOwogICAgICAgICAgICB9CiAgfQogIHJldHVybiAwOwogIH0=