{ NOTE: it is recommended to use this even if you don't understand the following code }

const
    MAXN = 100000;

var
	op, a, b, k     : LongInt;
    N, Q, ans, i, j : LongInt;
    edges           : Array[0..2-1] of Array[0..MAXN-2] of LongInt;

begin
{
    uncomment the two following lines if you want to read/write from files
    assign(input,  'input.txt');  reset(input);
    assign(output, 'output.txt'); rewrite(output);
}

    ReadLn(N);

    for j:=0 to N-2 do begin
        for i:=0 to 2-1 do
            Read(edges[j][i]);
        ReadLn();
    end;

    ReadLn(Q);
	for i:=0 to Q-1 do begin
		Read(op);
		if op = 1 then
		begin
			Read(a);
			Read(b);
		end
		else
		begin
			Read(k);
			ans:=0;
			WriteLn(ans);
		end;
	end;
end.
