Problem: Write a program which manipulates a weighted rooted tree $T$ with the following operations:

* $add(v,w)$: add $w$ to the edge which connects node $v$ and its parent

* $getSum(u)$: report the sum of weights of all edges from the root to node $u$



The given tree $T$ consists of $n$ nodes and every node has a unique ID from $0$ to $n-1$ respectively where ID of the root is $0$. Note that all weights are initialized to zero.

Constraints

* All the inputs are given in integers
* $ 2 \leq n \leq 100000 $
* $ c_j < c_{j+1} $   $( 1 \leq j \leq k-1 )$
* $ 2 \leq q \leq 200000 $
* $ 1 \leq u,v \leq n-1 $
* $ 1 \leq w \leq 10000 $

Input

The input is given in the following format.

$n$
$node_0$
$node_1$
$node_2$
$:$
$node_{n-1}$
$q$
$query_1$
$query_2$
$:$
$query_{q}$


The first line of the input includes an integer $n$, the number of nodes in the tree.

In the next $n$ lines,the information of node $i$ is given in the following format:


ki c1 c2 ... ck


$k_i$ is the number of children of node $i$, and $c_1$ $c_2$ ... $c_{k_i}$ are node IDs of 1st, ... $k$th child of node $i$.

In the next line, the number of queries $q$ is given. In the next $q$ lines, $i$th query is given in the following format:


0 v w


or


1 u


The first integer represents the type of queries.'0' denotes $add(v, w)$ and '1' denotes $getSum(u)$.

Output

For each $getSum$ query, print the sum in a line.

Examples

Input

6
2 1 2
2 3 5
0
0
0
1 4
7
1 1
0 3 10
1 2
0 4 20
1 3
0 5 40
1 4


Output

0
0
10
60


Input

4
1 1
1 2
1 3
0
6
0 3 1000
0 2 1000
0 1 1000
1 1
1 2
1 3


Output

1000
2000
3000


Input

2
1 1
0
4
0 1 1
1 1
0 1 1
1 1


Output

1
2

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define NUM 100005

struct Edge{
	Edge(int arg_to){
		to = arg_to;
	}
	int to;
};

struct Info{

	Info(){
		to_root_sum_weight = 0;
	}
	Info(ll arg_to_root_sum_weight){
		to_root_sum_weight = arg_to_root_sum_weight;
	}

	ll to_root_sum_weight; //根方向の辺に累積された重さ
};

struct Data{
	int parent,head,depth,size;
};

int V,N;
int root,global_index;
int index_table[NUM];
ll K;
Data data[NUM];
Info  table[8*NUM]; //セグ木
vector<Edge> G[NUM];

void init(int first_N){
	while(N < first_N)N *= 2;
}

Info merge(Info a,Info b){

	if(a.to_root_sum_weight == -1)return b; //aが範囲外
	if(b.to_root_sum_weight == -1)return a; //bが範囲外

    Info ret = Info(a.to_root_sum_weight+b.to_root_sum_weight);

    return ret;
}

void add(int loc,ll value){

	loc += N-1;

	table[loc].to_root_sum_weight += value; //根方向に加算

	int parent = (loc-1)/2;
	int left_child,right_child;

	while(true){

		left_child = 2*parent+1; //根に近い子
		right_child = 2*parent+2; //葉に近い子

		table[parent] = merge(table[left_child], table[right_child]);

		if(parent == 0){

			break;

		}else{

			parent = (parent-1)/2;
		}
	}
}

int makeTree(int node_id,int parent,int depth){

	data[node_id].depth = depth;
	data[node_id].parent = parent;
	data[node_id].size = 1; //部分木のノード数(自分&子孫)

	int child;

	for(int i = 0; i < G[node_id].size(); i++){

		child = G[node_id][i].to;
		if(child == parent)continue;

		data[node_id].size += makeTree(child,node_id,depth+1);
	}

	return data[node_id].size;
}

void HLD(int node_id,int head,int parent){

	index_table[node_id] = global_index++; //★★根に近いものほど、番号が小さい(★左にある★)
	data[node_id].head = head;

	if(G[node_id].size() == 0)return;

	//子の中で、最大の重み(部分木のノード数)を持つものを探す
	int max_size = -BIG_NUM;
	int max_node_id = -1,child;

	for(int i = 0; i < G[node_id].size(); i++){

		child = G[node_id][i].to;
		if(child == parent)continue;

		if(max_size < data[child].size){

			max_size = data[child].size;
			max_node_id = child;
		}
	}

	if(max_node_id == -1)return;

	//最大の重みを持つ子へ(headは変わらず)
	HLD(max_node_id,head,node_id);

	//その他の子を処理(新しいラインを作る)
	for(int i = 0; i < G[node_id].size(); i++){

		child = G[node_id][i].to;
		if(child == parent || child == max_node_id)continue;

		HLD(child,child,node_id);
	}
}

//セグ木には、%Kの判定が済んだ値が保存されている
Info query(int search_left,int search_right,int node_id,int node_left,int node_right){

	//範囲外
	if(search_right < node_left || search_left > node_right)return Info(-1);

	//今回のノードの区間が、検索区間の部分区間である場合
	if(search_left <= node_left && search_right >= node_right){
		return table[node_id];
	}

	//今回のノードの区間に、一部検索区間と重なっている区間がある場合→再帰的に子どもに尋ねる
	Info left_info = query(search_left,search_right,2*node_id+1,node_left,(node_left+node_right)/2);
	Info right_info = query(search_left,search_right,2*node_id+2,(node_left+node_right)/2+1,node_right);

	return merge(left_info,right_info);
}

ll query(int from,int to){

	return query(index_table[from],index_table[to],0,0,N-1).to_root_sum_weight;
}

//node_id～rootへのコストを求める
ll get_weight(int node_id){

	ll ret = 0;
	int head_node;

	while(true){

		head_node = data[node_id].head;

		//node_id～同じラインのヘッドのコストを求める(セグ木演算)
		ret += query(head_node,node_id);

		if(head_node == root)break; //rootまで到達したらbreak

		node_id = data[head_node].parent;
	}

	return ret;
}

int main(){

	int first_N;

	scanf("%d",&first_N);

	int num;
	int from,to;

	for(from = 0; from <= first_N-1; from++){

		scanf("%d",&num);
		for(int i = 0; i < num; i++){
			scanf("%d",&to);
			G[from].push_back(Edge(to));
			G[to].push_back(Edge(from));
		}
	}

	root = 0;

	makeTree(root,-1,0);
	global_index = 0;
	HLD(root,root,-1);  //0スタートでdfs木を作ったので、0がrootとなる

	//dfs木をセグメント木に変換する
	N = 1;
	init(first_N);

	for(int i = 0; i < N; i++){

		add(i,0); //セグ木の構築
	}

	int num_query;
	scanf("%d",&num_query);

	int node_id,command,add_weight;

	for(int loop = 0; loop < num_query; loop++){

		scanf("%d",&command);

		if(command == 0){

			scanf("%d %d",&node_id,&add_weight);
			add(index_table[node_id],add_weight);

		}else{

			scanf("%d",&node_id);
			printf("%lld\n",get_weight(node_id));
		}
	}

	return 0;
}