import sys import os import inspect input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) if os.getenv("TKTKLOCAL", False): def debug(*arg, sep=" ", end="\n"): print(*arg, sep=sep, end=end, file=sys.stderr) def debug_indent(*arg, sep=" ", end="\n", indent=" "): frame = inspect.currentframe().f_back par_func = inspect.getframeinfo(frame).function if par_func == "": debug(*arg, sep=sep, end=end) return frame_stack = inspect.stack() if len(frame_stack) > 30: return depth = sum(f.function == par_func for f in frame_stack) debug(indent * (depth - 1), end="") debug(*arg, sep=sep, end=end) else: def debug(*arg, **kwarg): pass def debug_indent(*arg, **kwarg): pass class FenwickTree(object): def __init__(self, n): self.n = n self.log = n.bit_length() self.data = [0] * n def _sum(self, r): s = 0 while r > 0: s += self.data[r - 1] r -= r & -r return s def add(self, p, x): """ a[p] += xを行う""" p += 1 while p <= self.n: self.data[p - 1] += x p += p & -p def sum(self, l, r): """a[l] + a[l+1] + .. + a[r-1]を返す""" return self._sum(r) - self._sum(l) def lower_bound(self, x): """a[0] + a[1] + .. a[i] >= x となる最小のiを返す""" if x <= 0: return -1 i = 0 k = 1 << self.log while k: if i + k <= self.n and self.data[i + k - 1] < x: x -= self.data[i + k - 1] i += k k >>= 1 return i def __repr__(self): res = [self.sum(i, i+1) for i in range(self.n)] return " ".join(map(str, res)) class FenwickTree_rangeADDrangeSUM: def __init__(self, n) -> None: self.n = n self.bit0 = FenwickTree(n) self.bit1 = FenwickTree(n) def range_add(self, l, r, x): """ add x to A[l, r) """ self.bit0.add(l, -x * l) self.bit0.add(r, x * r) self.bit1.add(l, x) self.bit1.add(r, -x) def add(self, p, x): """ add x to A[p] """ self.range_add(p, p+1, x) def __sum(self, r): return self.bit1._sum(r) * r + self.bit0._sum(r) def sum(self, l, r): """ get sum A[l, r) """ return self.__sum(r) - self.__sum(l) def __repr__(self): res = [self.sum(i, i+1) for i in range(self.n)] return " ".join(map(str, res)) def main(): N = int(input()) G = [[] for _ in range(N)] par = [-1] * N dist = [0] * N for _ in range(N - 1): a, b, w = map(int, input().split()) G[a].append((b, w)) par[b] = a dist[b] = w iter = [0] * N go_from = [-1] * N go_to = [-1] * N back_from = [-1] * N back_to = [-1] * N memo_go = [] memo_back = [] go_from[0] = 0 back_from[0] = 0 que = [0] while que: s = que[-1] if iter[s] < len(G[s]): t, d = G[s][iter[s]] iter[s] += 1 que.append(t) memo_go.append(d) go_from[t] = len(memo_go) back_from[t] = len(memo_back) else: que.pop() go_to[s] = len(memo_go) back_to[s] = len(memo_back) memo_back.append(dist[s]) debug() debug(memo_go) debug(go_from) debug(go_to) debug() debug(memo_back) debug(back_from) debug(back_to) bit_go = FenwickTree_rangeADDrangeSUM(N) bit_back = FenwickTree_rangeADDrangeSUM(N) for i, d in enumerate(memo_go): bit_go.add(i, d) for i, d in enumerate(memo_back): bit_back.add(i, d) Q = int(input()) for _ in range(Q): flag, *arg = map(int, input().split()) if flag == 1: a, x = arg bit_go.range_add(go_from[a], go_to[a], x) bit_back.range_add(back_from[a], back_to[a], x) else: a, = arg print(bit_go.sum(0, go_from[a]) - bit_back.sum(0, back_from[a])) main()