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.
#include <bits/stdc++.h>
using namespace std;
int n, m, tot;
int head[400010], dep[400010], dfn[400010];
struct edge {
  int fr, to, nxt;
} e[400010 << 1];
int read() {
  int s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    s = (s << 1) + (s << 3) + ch - '0', ch = getchar();
  return s * w;
}
void add(int fr, int to) {
  e[++tot] = (edge){fr, to, head[fr]};
  head[fr] = tot;
}
namespace Seg {
int b[400010], w[400010];
void pushup(int x) {
  b[x] = b[x << 1] + b[x << 1 | 1];
  w[x] = w[x << 1] + w[x << 1 | 1];
}
void build(int x, int l, int r) {
  if (l == r) {
    b[x] = 1;
    return;
  }
  int mid = l + r >> 1;
  build(x << 1, l, mid);
  build(x << 1 | 1, mid + 1, r);
  pushup(x);
}
void update_b(int x, int l, int r, int pos) {
  if (l == r) {
    w[x] = 0;
    b[x] = 1;
    return;
  }
  int mid = l + r >> 1;
  if (pos <= mid)
    update_b(x << 1, l, mid, pos);
  else
    update_b(x << 1 | 1, mid + 1, r, pos);
  pushup(x);
}
void update_w(int x, int l, int r, int pos) {
  if (l == r) {
    b[x] = 0;
    w[x] = 1;
    return;
  }
  int mid = l + r >> 1;
  if (pos <= mid)
    update_w(x << 1, l, mid, pos);
  else
    update_w(x << 1 | 1, mid + 1, r, pos);
  pushup(x);
}
int judge(int x, int l, int r, int L, int R) {
  int ans = 0;
  if (L <= l && R >= r) return w[x];
  int mid = l + r >> 1;
  if (L <= mid) ans += judge(x << 1, l, mid, L, R);
  if (R >= mid + 1) ans += judge(x << 1 | 1, mid + 1, r, L, R);
  return ans;
}
int query(int x, int l, int r, int L, int R) {
  int ans = 0;
  if (L <= l && R >= r) return b[x];
  int mid = l + r >> 1;
  if (L <= mid) ans += query(x << 1, l, mid, L, R);
  if (R >= mid + 1) ans += query(x << 1 | 1, mid + 1, r, L, R);
  return ans;
}
}  // namespace Seg
namespace Cut {
int cnt = 0;
int top[400010], son[400010];
int fa[400010], siz[400010];
void dfs1(int u, int fat) {
  dep[u] = dep[fat] + 1;
  fa[u] = fat;
  siz[u] = 1;
  for (int i = head[u]; i; i = e[i].nxt) {
    int to = e[i].to;
    if (to == fat) continue;
    dfs1(to, u);
    siz[u] += siz[to];
    if (siz[son[u]] < siz[to]) son[u] = to;
  }
}
void dfs2(int u, int tp) {
  top[u] = tp;
  dfn[u] = ++cnt;
  if (son[u]) dfs2(son[u], tp);
  for (int i = head[u]; i; i = e[i].nxt) {
    int to = e[i].to;
    if (to == fa[u] || to == son[u]) continue;
    dfs2(to, to);
  }
}
int query_w(int fr, int to) {
  int ans = 0;
  while (top[fr] != top[to]) {
    if (dep[top[fr]] < dep[top[to]]) swap(fr, to);
    ans += Seg::judge(1, 1, n, dfn[top[fr]], dfn[fr]);
    fr = fa[top[fr]];
  }
  if (dep[fr] > dep[to]) swap(fr, to);
  ans += Seg::judge(1, 1, n, dfn[fr] + 1, dfn[to]);
  return ans;
}
int query_b(int fr, int to) {
  int ans = 0;
  while (top[fr] != top[to]) {
    if (dep[top[fr]] < dep[top[to]]) swap(fr, to);
    ans += Seg::query(1, 1, n, dfn[top[fr]], dfn[fr]);
    fr = fa[top[fr]];
  }
  if (dep[fr] > dep[to]) swap(fr, to);
  ans += Seg::query(1, 1, n, dfn[fr] + 1, dfn[to]);
  return ans;
}
}  // namespace Cut
int main() {
  n = read();
  for (int i = 1, fr, to; i < n; i++) {
    fr = read();
    to = read();
    add(fr, to);
    add(to, fr);
  }
  Seg::build(1, 1, n);
  Cut::dfs1(1, 0);
  Cut::dfs2(1, 1);
  m = read();
  for (int i = 1, opt, u, v; i <= m; i++) {
    opt = read();
    u = read();
    if (opt == 1)
      Seg::update_b(1, 1, n,
                    dep[e[u * 2].fr] < dep[e[u * 2].to] ? dfn[e[u * 2].to]
                                                        : dfn[e[u * 2].fr]);
    else if (opt == 2)
      Seg::update_w(1, 1, n,
                    dep[e[u * 2].fr] < dep[e[u * 2].to] ? dfn[e[u * 2].to]
                                                        : dfn[e[u * 2].fr]);
    else {
      v = read();
      if (Cut::query_w(u, v))
        printf("-1\n");
      else
        printf("%d\n", Cut::query_b(u, v));
    }
  }
  return 0;
}
