#include using namespace std; #include using namespace atcoder; using mint=modint998244353; //1000000007; using ll=long long; using pp=pair; #define sr string #define vc vector #define fi first #define se second #define rep(i,n) for(int i=0;i<(int)n;i++) #define pb push_back #define all(v) v.begin(),v.end() #define pque priority_queue #define bpc(a) __builtin_popcount(a) int main(){ int n,q;cin>>n>>q; vcp(n); rep(i,n)p[i]=i; vcx(n,0),xx(n,0); vc v(n,vc(0)); rep(i,n)v[i].pb(i); auto par=[&](auto f,int a)->int{ if(p[a]==a)return a; return p[a]=f(f,p[a]); }; auto merge=[&](int a,int b)->void{ a=par(par,a); b=par(par,b); if(a==b)return; if(v[a].size()>v[b].size())swap(a,b); for(auto au:v[a]){ x[au]+=xx[a]-xx[b]; v[b].pb(au); } p[a]=b; return; }; rep(z,q){ int t,a,b;cin>>t>>a>>b; if(t==1)merge(a-1,b-1); if(t==2)xx[par(par,a-1)]+=b; if(t==3)cout<