#include using namespace std; using ll=long long; using vin=vector; using vll=vector; using vvin=vector>; using vvll=vector>; using vstr=vector; using vvstr=vector>; using vch=vector; using vvch=vector>; using vbo=vector; using vvbo=vector>; using vpii=vector>; using pqsin=priority_queue,greater>; #define mp make_pair #define rep(i,n) for(int i=0;i<(int)(n);i++) #define rep2(i,s,n) for(int i=(s);i<(int)(n);i++) #define all(v) v.begin(),v.end() #define decp(n) cout< que; init(n); vin wei(n+1,0); rep(i,q){ int t,a,b; scanf("%d %d %d",&t,&a,&b); if(t==1)unite(a,b); if(t==2){ for(auto kid:baby[root(a)])wei[kid]+=b; } if(t==3)que.push(wei[a]); } while(que.size()){ printf("%d\n",que.front()); que.pop(); } } void init(int n){ rep(i,n+1){ par[i]=i; deep[i]=0; baby[i].push_back(i); } } int root(int x){ if(par[x]==x)return x; else return par[x]=root(par[x]); } void unite(int x,int y){ x=root(x); y=root(y); if(x==y)return; if(deep[x]