#include #define rep(i,n) for(int i = 0; i < (n); ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) #define srep(i,s,t) for (int i = s; i < t; ++i) using namespace std; typedef long long int ll; typedef pair P; #define yn {puts("Yes");}else{puts("No");} const int MAX_N = 1000100; int par_[MAX_N]; // 親 int rank_[MAX_N]; // 木の深さ ll val[MAX_N]; // n要素で初期化 void UFinit(){ for(int i=0;i> n >> q; vector ans; rep(i,q){ int t, a, b; cin >> t >> a >> b; if(t == 1){ if(same(a,b))continue; unite(a,b); }else if(t == 2){ int x = find_(a); val[x] += b; }else if(t == 3){ ans.push_back(calc(a)); } } rep(i,ans.size()) cout << ans[i] << endl; return 0; }