Let's define a non-oriented connected graph of n vertices and n - 1 edges as a beard, if all of its vertices except, perhaps, one, have the degree of 2 or 1 (that is, there exists no more than one vertex, whose degree is more than two). Let us remind you that the degree of a vertex is the number of edges that connect to it. 

Let each edge be either black or white. Initially all edges are black.

You are given the description of the beard graph. Your task is to analyze requests of the following types: 

  * paint the edge number i black. The edge number i is the edge that has this number in the description. It is guaranteed that by the moment of this request the i-th edge is white 
  * paint the edge number i white. It is guaranteed that by the moment of this request the i-th edge is black 
  * find the length of the shortest path going only along the black edges between vertices a and b or indicate that no such path exists between them (a path's length is the number of edges in it) 



The vertices are numbered with integers from 1 to n, and the edges are numbered with integers from 1 to n - 1.

Input

The first line of the input contains an integer n (2 ≤ n ≤ 105) — the number of vertices in the graph. Next n - 1 lines contain edges described as the numbers of vertices vi, ui (1 ≤ vi, ui ≤ n, vi ≠ ui) connected by this edge. It is guaranteed that the given graph is connected and forms a beard graph, and has no self-loops or multiple edges.

The next line contains an integer m (1 ≤ m ≤ 3·105) — the number of requests. Next m lines contain requests in the following form: first a line contains an integer type, which takes values ​​from 1 to 3, and represents the request type.

If type = 1, then the current request is a request to paint the edge black. In this case, in addition to number type the line should contain integer id (1 ≤ id ≤ n - 1), which represents the number of the edge to paint.

If type = 2, then the current request is a request to paint the edge white, its form is similar to the previous request.

If type = 3, then the current request is a request to find the distance. In this case, in addition to type, the line should contain two integers a, b (1 ≤ a, b ≤ n, a can be equal to b) — the numbers of vertices, the distance between which must be found.

The numbers in all lines are separated by exactly one space. The edges are numbered in the order in which they are given in the input.

Output

For each request to "find the distance between vertices a and b" print the result. If there is no path going only along the black edges between vertices a and b, then print "-1" (without the quotes). Print the results in the order of receiving the requests, separate the numbers with spaces or line breaks.

Examples

Input

3
1 2
2 3
7
3 1 2
3 1 3
3 2 3
2 2
3 1 2
3 1 3
3 2 3


Output

1
2
1
1
-1
-1


Input

6
1 5
6 4
2 3
3 5
5 6
6
3 3 4
2 5
3 2 6
3 1 2
2 3
3 3 1


Output

3
-1
3
2

Note

In the first sample vertices 1 and 2 are connected with edge number 1, and vertices 2 and 3 are connected with edge number 2. Before the repainting edge number 2 each vertex is reachable from each one along the black edges. Specifically, the shortest path between 1 and 3 goes along both edges.

If we paint edge number 2 white, vertex 3 will end up cut off from other vertices, that is, no path exists from it to any other vertex along the black edges.
import java.io.*;
import java.util.*;

public class Program
{
	private static StreamTokenizer in;
	private static PrintWriter out;

	public static int[] orderNoFromLeaf;

	
	private static void init() throws FileNotFoundException, IOException
	{
		Boolean oj = System.getProperty("ONLINE_JUDGE") != null;
		Reader r = oj ? new InputStreamReader(System.in) : new FileReader("Input.txt");
		Writer w = oj ? new OutputStreamWriter(System.out) : new FileWriter("Output.txt");
		
		in = new StreamTokenizer(new BufferedReader(r));
		out = new PrintWriter(w);
	}
	private static void close()
	{
		if (out != null)
		{
			out.flush();
			out = null;
		}
		if (in != null)
			in = null;
	}
	
	public static void main(String[] args) throws IOException
	{
		init();
		//print();
		solve();
		close();
	}
	@SuppressWarnings("unused")
	private static void print()
	{
	}
	private static void solve()	throws IOException
	{
		in.nextToken();
		int n = (int)in.nval;
		
		List<ArrayList<Struct2>> ar2 = new ArrayList<ArrayList<Struct2>>();
		int[] dgr = new int[n];
		Map<Integer, Path> map = new Hashtable<Integer, Path>();
		Struct[] edges = new Struct[n - 1];
		int[] leafNo = new int[n];
		orderNoFromLeaf = new int[n];
		
		for (int i = 0; i < n; i++)
		{
			ar2.add(new ArrayList<Struct2>());
			dgr[i] = 0;
			orderNoFromLeaf[i] = 0;
			leafNo[i] = -1;
		}
		
		int rv = 0;
		for (int i = 0; i < n - 1; i++)
		{
			in.nextToken();
			int v = (int)in.nval - 1;
			in.nextToken();
			int u = (int)in.nval - 1;
			
			ar2.get(v).add(new Struct2(u, i));
			ar2.get(u).add(new Struct2(v, i));
			
			dgr[v]++;
			dgr[u]++;
			
			if (dgr[rv] < dgr[v])
				rv = v;
			if (dgr[rv] < dgr[u])
				rv = u;
			
			edges[i] = new Struct(v, u);
		}
		
		for (int i = 0; i < n; i++)
		{
			if (dgr[i] == 1 && i != rv)
			{
				Path path = new Path();
				int oldPrnt = i;
				int prnt = ar2.get(i).get(0).vertex;
				int oldPrnt2 = -1;
				int orderNo = 0;
				while (prnt != rv)
				{
					path.base.add(new Struct(oldPrnt, prnt));
					orderNoFromLeaf[oldPrnt] = orderNo++;
					leafNo[oldPrnt] = i;
					
					oldPrnt2 = oldPrnt;
					oldPrnt = prnt;
					prnt = ar2.get(oldPrnt).get(0).vertex;
					if (oldPrnt2 == prnt)
						prnt = ar2.get(oldPrnt).get(1).vertex;
				}
				path.base.add(new Struct(oldPrnt, rv));
				orderNoFromLeaf[oldPrnt] = orderNo++;
				leafNo[oldPrnt] = i;
				
				path.constructTree();
				map.put(i, path);
			}
		}
		orderNoFromLeaf[rv] = Integer.MAX_VALUE;
		
		in.nextToken();
		int m = (int)in.nval;

		for (int i = 0; i < m; i++)
		{
			in.nextToken();
			int t = (int)in.nval;

			if(t == 1 || t == 2)
			{
				in.nextToken();
				int e = (int)in.nval - 1;
				boolean isBlack = t == 1;
				Struct s = edges[e];
				int x = s.v;
				int y = s.u;
				if (orderNoFromLeaf[s.u] < orderNoFromLeaf[s.v])
				{
					x = s.u;
					y = s.v;
				}
				
				int leaf = leafNo[x];
				map.get(leaf).paint(x, y, isBlack);
			}
			else
			{
				in.nextToken();
				int x = (int)in.nval - 1;
				in.nextToken();
				int y = (int)in.nval - 1;
				
				if (x == y)
				{
					out.println(0);
				}
				else
				{
					int orderNoX = orderNoFromLeaf[x];
					int orderNoY = orderNoFromLeaf[y];
					if (orderNoY < orderNoX)
					{
						x = x + y;
						y = x - y;
						x = x - y;

						orderNoX = orderNoX + orderNoY;
						orderNoY = orderNoX - orderNoY;
						orderNoX = orderNoX - orderNoY;
					}

					int leafX = leafNo[x];
					int leafY = leafNo[y];
					
					if (leafY == -1)
						leafY = leafX;
					
					if (leafX == leafY)
					{

						Path path = map.get(leafX);
						if (path.IsRoad(x, y))
						{
							if (y == rv)
								out.println(path.base.size() - orderNoX);
							else
								out.println(orderNoY - orderNoX);
						}
						else
						{
							out.println(-1);
						}
					}
					else
					{
						Path pathX = map.get(leafX);
						Path pathY = map.get(leafY);
						if (pathX.IsRoad(x, rv) && pathY.IsRoad(y, rv))
						{
							out.println(pathX.base.size() - orderNoX + pathY.base.size() - orderNoY);
						}
						else
						{
							out.println(-1);
						}
					}
				}
			}
		}
	}
}
class Struct
{
	public int v;
	public int u;
	public boolean isBlack;
	
	public Struct(int _v, int _u)
	{
		this.v = _v;
		this.u = _u;
		this.isBlack = true;
	}
	public Struct(int _v, int _u, boolean _isBlack)
	{
		this.v = _v;
		this.u = _u;
		this.isBlack = _isBlack;
	}
}
class Path
{
	public List<Struct> base;
	public Struct[] tree;
	
	public Path()
	{
		this.base = new ArrayList<Struct>();
	}
	
	public void constructTree()
	{
		int sz = this.base.size();
		int treeSz = 1;
		while (treeSz < sz)
			treeSz *= 2;
		
		treeSz = treeSz * 2 - 1;
		this.tree = new Struct[treeSz];
		SegmentTree.constructTree(this.base, tree, 0, sz - 1, 0);
	}
	public boolean IsRoad(int x, int y)
	{
		return SegmentTree.query(this.tree, x, y, 0);
	}
	public void paint(int x, int y, boolean isBlack)
	{
		SegmentTree.set(this.tree, new Struct(x, y, isBlack), 0);
	}
}
class Struct2
{
	public int vertex;
	public int edge;
	
	public Struct2(int _vertex, int _edge)
	{
		this.vertex = _vertex;
		this.edge = _edge;
	}
}
class SegmentTree
{
	public static void constructTree(List<Struct> base, Struct[] tree, int l, int h, int pos)
	{
		if (l == h)
		{
			tree[pos] = base.get(l);
			return;
		}
		int t = (l + h) / 2;
		constructTree(base, tree, l, t, pos * 2 + 1);
		constructTree(base, tree, t + 1, h, pos * 2 + 2);
		
		tree[pos] = new Struct(tree[2 * pos + 1].v, tree[2 * pos + 2].u);
	}
	
	public static boolean query(Struct[] tree, int ql, int qh, int p)
	{
		if (p >= tree.length)
			return true;
		
		Struct s = tree[p];
		if (s == null)
			return true;
		
		if (Program.orderNoFromLeaf[ql] <= Program.orderNoFromLeaf[s.v] && Program.orderNoFromLeaf[qh] >= Program.orderNoFromLeaf[s.u])
		{
			return s.isBlack;
		}
		
		if (Program.orderNoFromLeaf[ql] > Program.orderNoFromLeaf[s.u] || Program.orderNoFromLeaf[qh] < Program.orderNoFromLeaf[s.v])
		{
			return true;
		}
		return query(tree, ql, qh, p * 2 + 1) & query(tree, ql, qh, p * 2 + 2);
	}
	
	public static void set(Struct[] tree, Struct leaf, int pos)
	{
		Struct s = tree[pos];
		if (s.v == leaf.v && s.u == leaf.u)
		{
			s.isBlack = leaf.isBlack;
			return;
		}
		
		int newPos = pos * 2 + 1;
		if (newPos >= tree.length)
			return;
		
		Struct s1 = tree[newPos];
		
		if (!(Program.orderNoFromLeaf[s1.v] <= Program.orderNoFromLeaf[leaf.v] && Program.orderNoFromLeaf[s1.u] >= Program.orderNoFromLeaf[leaf.u]))
		{
			newPos++;
			s1 = tree[newPos];
		}

		set(tree, leaf, newPos);
		
		boolean childIsBlack1 = true;
		boolean childIsBlack2 = true;
		if (pos * 2 + 1 < tree.length)
			childIsBlack1 = tree[pos * 2 + 1].isBlack;
		if (pos * 2 + 2 < tree.length)
			childIsBlack2 = tree[pos * 2 + 2].isBlack;
		
		tree[pos].isBlack = childIsBlack1 & childIsBlack2;
	}
}