#include <bits/stdc++.h>
#define ll long long
#define ii pair<int,int>
#define fi first
#define se second
using namespace std;
const int N=2e3+5;
int n;
int k=2;
ll dp[N];
vector<ii>v1[N];
int in[N],out[N];
int t=0;
void dfs(int u,int pr){
for(auto x:v1[u]){
int node=x.fi;
int s1=x.se;
if(node!=pr){
dp[node]=dp[u]^s1;
dfs(node,u);
}
}
}
void dfs1(int u,int pr){
t++;
in[u]=out[u]=t;
for(auto x:v1[u]){
int node=x.fi;
int s1=x.se;
if(node!=pr){
dfs1(node,u);
out[u]=max(out[u],out[node]);
}
}
}
int main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
cin >>n;
for(int i=1;i<=n;i++){
string x;
cin >>x;
if(x=="Add"){
int y,z;
cin >>y >>z;
v1[y].push_back({k,z});
v1[k].push_back({y,z});
for(int i=1;i<=n;i++){
in[i]=0;
out[i]=0;
}
dfs1(1,-1);
t=0;
k++;
}
else{
int y,z;
cin >>y >>z;
ll tong=0;
dfs(1,-1);
for(int i=1;i<=n;i++){
if(in[i]>=in[z] && out[i]<=out[z]){
tong=max(tong,dp[y]^dp[i]);
}
}
cout << tong << "\n";
}
}
return 0;
}