$Jaggu$ monkey a friend of $Choota$ $Bheem$ a great warrior of $Dholakpur$. He gets everything he wants. Being a friend of $Choota$ $Bheem$ he never has to struggle for anything, because of this he is in a great debt of $Choota$ $Bheem$, he really wants to pay his debt off.
Finally the time has come to pay his debt off, $Jaggu$ is on a magical tree. He wants to collect apples from different branches but he is in a hurry. $Botakpur$ has attacked on $Dholakpur$ and $Bheem$ is severely injured, as been instructed by the village witch, $Bheem$ can only be saved by the apples of the magical tree. Each apple is placed in Tree Node structure and each apple has some sweetness. Now there's a problem as $Jaggu$ is also injured so he can only slide downwards and alse is collecting apples in his hand so he can't climb. You would be given $Q$ queries. Queries are of 2 type :-
- 
Ending Node Node of $Jaggu$ is given. $format$ - type of query node -(1 2)
- 
Sweetness of Apple on a given node is changed. $format$ - type of query node new sweetness(2 3 10)
$Note$: $Jaggu$ is always on the top of tree initially in each query.The sweetness is always positive.
Help $Jaggu$ in saving $Bheem$

-----Input:-----
- First line contains $N$ - (number of nodes).  
- Next line contains $N$ integers with space giving sweetness of apple on Nodes $(1 to N)$
- Next $N-1$ lines contain  $N1$ $N2$ connected nodes.
- Next line contains single integer $Q$ Number of queries

-----Output:-----
- For each query of type 1, print total sweetness of apples. 

-----Constraints-----
- $1 \leq N \leq 10^4$
- $2 \leq Q \leq 10^4$

-----Sample Input:-----
10
10 12 6 8 1 19 0 5 13 17
1 2
1 3
1 4
3 10
4 8
8 9
4 5
5 7
5 6
3
1 1
2 3 20
1 8

-----Sample Output:-----
10
23

-----EXPLANATION:-----
This sweetness array is :
$[10,2,6,8,1,19,0,5,13,17]$
The tree is:
1   

/  |   \      

2    3     4     

/    /    \      

10     8        5   

/        /    \     

9         7        6

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = 'counter = -1\ndef flattree(node):\n    nonlocal counter\n    if visited[node]==1:\n        return\n    else:\n        visited[node]=1\n        counter += 1\n        in_counter[node] = counter\n\n        flat_tree[counter] = sweetness[node]\n\n        for i in graph[node]:\n            if visited[i]==0:\n                flattree(i)\n        counter += 1\n        out_counter[node] = counter\n        flat_tree[counter] = -sweetness[node]\n    return\n\n\ndef getsum(BITTree, i):\n    s = 0  # initialize result\n    i = i + 1\n    while i > 0:\n        s += BITTree[i]\n        i -= i & (-i)\n    return s\n\ndef updatebit(BITTree, n, i, v):\n    i += 1\n    while i <= n:\n        BITTree[i] += v\n        i += i & (-i)\n\ndef construct(arr, n):\n    BITTree = [0] * (n + 1)\n    for i in range(n):\n        updatebit(BITTree, n, i, arr[i])\n    return BITTree\n\nfrom collections import defaultdict\nn = int(input())\nsweetness = list(map(int, input().split()))\ngraph = defaultdict(list)\n\nfor i in range(n-1):\n    n1, n2 = list(map(int, input().split()))\n    graph[n1-1].append(n2-1)\n    graph[n2-1].append(n1-1)\n\nflat_tree = [0]*(2*n+1)\nin_counter = [0]*n\nout_counter = [0]*n\nvisited = [0]*n\nflattree(0)\n# print(flat_tree)\n# print(in_counter)\n# print(out_counter)\nfenwicktree = construct(flat_tree, 2*n)\n\nq = int(input())\nfor i in range(q):\n    query = list(map(int, input().split()))\n    if query[0] == 1:\n        node = query[1] - 1\n        answer = getsum(fenwicktree, in_counter[node])\n        print(answer)\n    else:\n        node = query[1]-1\n        updatebit(flat_tree, (2*n), in_counter[node], query[2])\n        updatebit(flat_tree, (2*n), out_counter[node], -query[2])\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: