#include #define rep(i, a, n) for(int i = a; i < n; i++) using namespace std; using ll = long long; using P = pair; vector to[500005]; vector ans; vector done; void dfs(int v, int p = -1, int b = 0){ for(auto u : to[v]){ if(u == p) continue; if(done[u]) continue; ans[u] += b; done[v] = 1; dfs(u, v, b); } } int main() { int n, q; cin >> n >> q; ans.resize(n); done.resize(n); rep(i, 0, q){ int t, a, b; cin >> t >> a >> b; a--; if(t == 1){ b--; to[a].push_back(b); to[b].push_back(a); } else if(t == 2){ rep(j, 0, n){ done[n] = 0; } ans[a] += b; done[a] = 1; dfs(a, -1, b); } else{ cout << ans[a] << endl; } } return 0; }