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.
// give black edge weight as 0 and white edge as 1. now if sum of edges between two
// vertices is zero then print distance
import java.util.*;
import java.io.*;
public class lp1{
static int  N =400400, LOGN = 20;
static int n,q,ptr,chainNo;
static int subSize[] = new int[N];   // size of the subtree
static int depth[] = new int[N];     // depth of each ode
static int chainInd[] = new int[N];  // chainNo in which node i belongs
static int chainHead[] = new int[N]; // head of chain i
static int base[] = new int[N];      // base array i.e dfs order
static int posInBase[] = new int[N]; // position of a vertex in base array
static int P[][] = new int[LOGN][N]; // to find lca using binary lifting
static int st[];                     // segment tree
static int ev[];                     // from this we will get edge id to vertex id
static class edge
{
    int d,idx;
    edge(int D,int id)
       { d=D; idx=id;}
}
static LinkedList<edge> g[];      // LinkedList for dfs


static  int LCA(int x , int y){
  if(depth[x] < depth[y]){
       int t =x;
        x=y;
        y=t;
  }
  int lg = 1; for(;(1<<lg) <= depth[x] ; lg ++);lg--;
  for(int i = lg ; i >= 0 ; i--)
    if(depth[x] - (1<<i) >= depth[y])
      x = P[i][x];
  if(x == y)return x;
  for(int i = lg ; i >= 0 ; i--)
    if(P[i][x] != -1 && P[i][x] != P[i][y]){
      x = P[i][x];
      y = P[i][y];
    }
  return P[0][x];
}
static void build() {  
  for (int i = n - 1; i > 0; --i) 
        st[i] = (st[i<<1] +st[i<<1|1]);
}

static void modify(int p,int value) { 
  for (st[p += n] = value; p > 1; p >>= 1) 
        st[p>>1] = (st[p]+st[p^1]);
}

static int query(int l, int r) {  // max on interval [l, r)
  int res = 0 ;
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if ((l&1)==1) res = (res+st[l++]);
    if ((r&1)==1) res = (res+st[--r]);
  }
  return res;
}

static void dfs(int root){  // iterative dfs
        P[0][root]=-1;
Stack<Integer> stack = new Stack<>();
        stack.push(root);
        boolean visit[] = new boolean[n];
                visit[0] = true;
        while( !stack.isEmpty() ) {
            int n = stack.pop();

            if( n >= 0 ) {
                if( n > 0 ) stack.push(-1 * n);
                for( edge c : g[n] )if(visit[c.d]==false){ visit[c.d]=true;stack.push(c.d); P[0][c.d]=n;ev[c.idx]=c.d; depth[c.d]=depth[n]+1;}
            }else {
                int sum = 1;
                n *= -1;
                for( edge c : g[n] ) sum += subSize[c.d];
                subSize[n] = sum;
            }
        }
        int n = 0;
        int sum = 1;
        for(edge c : g[n] ) sum += subSize[c.d];
        subSize[n] = sum;
} 
static int query_up(int u,int v){
   
   int uchain,vchain=chainInd[v];
   int ret=0;
    while(1>0){
        uchain=chainInd[u];
        if(uchain==vchain){
            ret=(ret+query(posInBase[v],posInBase[u]+1));
            break;
        }
      else{
        ret=(ret+query(posInBase[chainHead[uchain]],posInBase[u]+1));  
        u=P[0][chainHead[uchain]];
        }
    }
    return ret; 
}

static void update(int node ,int val) {
  int pos = posInBase[node];
    modify( pos,val); 
}
static class frame{
        int curNode,chainNo;
        frame(int cn,int chn){
              curNode =cn;
              chainNo = chn;
         }
}
static void hld(int curNode ,int p) {

        boolean visit[] = new boolean[n];
        Stack<frame> stack = new Stack<>();
        stack.push(new frame(curNode,0));
        visit[curNode]=true;
        int ctt=0;
        while( !stack.isEmpty() ) {
            frame fr = stack.pop();

            if(chainHead[fr.chainNo]==-1)
               chainHead[fr.chainNo]=fr.curNode;
                chainInd[fr.curNode]=fr.chainNo;
                posInBase[fr.curNode]=ptr;
                base[ptr++]=fr.curNode;
           
          
                int maxSubtreeIndex = -1,maxsize=0;
                for(edge c : g[fr.curNode] ) {
                    if( visit[c.d]==false && subSize[c.d] > maxsize ) {
                        maxsize = subSize[c.d];
                        maxSubtreeIndex = c.d;
                    }
                }
              if(maxSubtreeIndex!=-1)
                visit[maxSubtreeIndex]=true;
                

                for(edge c : g[fr.curNode] ) {
                    if(visit[c.d]==false ) {
                        visit[c.d]=true;
                        stack.push(new frame(c.d,++ctt));
                    }
                }
               if(maxSubtreeIndex!=-1)
                 stack.push(new frame(maxSubtreeIndex,fr.chainNo));
        }     
}  
public static void main(String[] args){
  Arrays.fill(chainHead , -1);
  n = sc.nextInt();
  st = new int[2*n];
  ev = new int[n];
  g  = new LinkedList[n]; 
  int col[] = new int[n];  // 0 means black and 1 means white
  for(int i=0;i<n;i++)
       g[i] = new LinkedList();
 for(int i=1;i<n;i++){
    int u = ni()-1;
    int v = ni()-1;
    g[u].add(new edge(v,i));
    g[v].add(new edge(u,i));
  }
  dfs(0);
  hld(0 , -1);
 
  for(int i = 1 ; i < LOGN ; i ++)
  for(int j = 1 ; j <= n ; j++)
    if(P[i-1][j] != -1)
      P[i][j] = P[i-1][P[i-1][j]];
     build(); 
q = ni();     
    for(int i=1;i<=q;i++) {
          int type = ni();
         if(type == 1) {
           int id = ni();
           if(col[ev[id]]==0)
              continue;
           else
              { update(ev[id],0); col[ev[id]]=0;}
       }
      else if(type==2)
           {
               int id = ni();
               if(col[ev[id]]==1)
                   continue;
               else
                    { update(ev[id],1); col[ev[id]]=1;}
           }
       else {
                 int u = ni()-1;
                 int v = ni()-1;
                 int lca = LCA(u,v);
                 int ans = query_up(u,lca) + query_up(v,lca) -2*col[lca];          
                 int dist = depth[u] + depth[v] -2*depth[lca];
                 if(ans==0)
                    pn(dist);
                 else
                    pn(-1);
        }
     }
          out.flush();
 }
////////////////////////////////// solution End here ////////////////////////////////////////////////////////////////////////
static class pair
	{
		int a,b;
		pair(){}
		pair(int c,int d){a=c;b=d;}
		@Override
		public int hashCode(){return (a+" "+b).hashCode();}
		@Override public boolean equals(Object c){if(a==((pair)c).a&&b==((pair)c).b)return true;return false;}
	}
static int get(int index)
        {
                return (index&(-index));
        }
static void add(int bit[],int index,int val)
        {
             while(index<bit.length)
               {
                    bit[index] = bit[index]+val;
                    index = index + get(index);
               }
        }
static int get(int bit[],int index)
         {
               int sum=0;
               while(index>0)
                {
                    sum = sum+bit[index];
                    index = index-get(index);
                }
              return sum;
         }
static void add(long bit[],int index,long val)
        {
             while(index<bit.length)
               {
                    bit[index] = bit[index]+val;
                    index = index + get(index);
               }
        }
static long get(long bit[],int index)
         {
               long sum=0;
               while(index>0)
                {
                    sum = sum+bit[index];
                    index = index-get(index);
                }
              return sum;
         } 
static void compress(int a[])
         {      
                int n = a.length;
                Integer ar[] = new Integer[n];
                for(int i=0;i<n;i++)
                     ar[i] = a[i];
                Arrays.sort(ar);
                HashMap<Integer,Integer> hm = new HashMap();
                int st=1;
                for(int i=0;i<n;i++)
                    if(!hm.containsKey(ar[i]))
                        hm.put(ar[i],st++);
                for(int i=0;i<n;i++)
                   a[i] = hm.get(a[i]);
         }
static int find(int x,int p[]){ if(x==p[x]) return x; return p[x]=find(p[x],p) ;}
static void union(int x,int y,int p[]){ int xr=find(x,p),yr=find(y,p); if(xr!=yr){ p[xr]=yr;} }
 
static int abs(int x){ return x>0 ? x : -x; }
static long abs(long x){ return x>0 ? x : -x; }
static long gcd(long a,long b){ if(a==0)return b; if(b==0) return a;if(b%a==0) return a;return gcd(b%a,a); }
static int gcd(int a,int b){ if(a==0)return b; if(b==0) return a; if(b%a==0) return a;return gcd(b%a,a); }
static long min(long a,long b){ return a<b ? a : b; }
static int min(int a,int b){ return a<b ? a : b; }
static long max(long a,long b){ return a>b ? a : b; }
static int max(int a,int b){ return a>b ? a : b; }
static long pow(long a,long b,long md){ long ans=1;  while(b>0){if(b%2==1) ans = (ans*a)%md; a = (a*a)%md; b = b/2;} return ans; }
static int log2n(long a){ int te=0; while(a>0) {a>>=1; ++te; } return te; }
 
 
static void subtract_1(char s[]){if(s[0]=='0') return;int n = s.length,i=n-1;while(s[i]=='0')i--;s[i] =(char)((int)(s[i]-'0') + 47);for(int j=i+1;j<n;j++)s[j]='9';}
static void reverse(char s[]){int i1=0,i2=s.length-1; while(i1<i2){char t=s[i1];s[i1]=s[i2];s[i2]=t; i1++;i2--;} }
static String reverse(String r){String s = "";int i= r.length()-1; while(i>=0){ s=s+r.charAt(i);i--;}return s;}
static boolean pal(char s[]){ int i1=0,i2=s.length-1; while(i1<i2){ if(s[i1]!=s[i2]) return false; i1++;i2--;} return true;}
static boolean pal(String s){int n = s.length(),i1=0,i2=n-1;while(i1<i2){if(s.charAt(i1)!=s.charAt(i2))return false;i1++; i2--;}return true;}
 
// Input OutPut Functions
static PrintWriter out = new PrintWriter(System.out);
static FastReader sc=new FastReader();
static int ni(){ int x = sc.nextInt();return(x); }
static long nl(){ long x = sc.nextLong(); return(x); }
static String n(){ String str = sc.next(); return(str); }
static String ns(){ String str = sc.nextLine(); return(str);}
static double nd(){double d = sc.nextDouble(); return(d); }
static int[] ai(int n){ int a[] = new int[n]; for(int i=0;i<n;i++) a[i] = ni(); return a; }
static long[] al(int n) {long a[] = new long[n]; for(int i=0;i<n;i++) a[i] = nl(); return a; }
static double[] ad(int n) { double a[]= new double[n]; for(int i=0;i<n;i++) a[i]=nd(); return a;} 
static void p(Object o){ out.print(o); }
static void pn(Object o){ out.println(o); } 
 
static class FastReader{ 
BufferedReader br; 
StringTokenizer st;   
public FastReader() { br = new BufferedReader(new InputStreamReader(System.in));  }   
String next(){while(st==null || !st.hasMoreElements()){try{st = new StringTokenizer(br.readLine());}catch (IOException  e){e.printStackTrace();}}return st.nextToken();} 
int nextInt(){ return Integer.parseInt(next()); } 
long nextLong(){ return Long.parseLong(next()); } 
double nextDouble(){return Double.parseDouble(next()); } 
String nextLine(){ String str = ""; try{ str = br.readLine();} catch (IOException e){ e.printStackTrace();} return str;} 
  } 
}