#include <bits/stdc++.h>
using namespace std;
long long dat[8 * 200000];
void add(int a, int b, long long x, int k, int l, int r) {
  if (b <= l || r <= a)
    ;
  else {
    if (l <= a && b <= r) dat[k] += x;
    if (1 < r - l) {
      add(a, b, x, k * 2 + 1, l, (l + r) / 2);
      add(a, b, x, k * 2 + 2, (l + r) / 2, r);
    }
  }
}
long long sum(int a, int b, int k, int l, int r) {
  if (a <= l && r <= b) {
    return dat[k];
  } else if (b <= l || r <= a) {
    return 0;
  } else {
    return sum(a, b, k * 2 + 1, l, (l + r) / 2) +
           sum(a, b, k * 2 + 2, (l + r) / 2, r);
  }
}
int n;
map<int, pair<int, int> > G[200000];
int vdfs[200000];
int depth[200000];
int parent[32][200000];
int dfs(int k, int b, int c, int d) {
  vdfs[k] = c;
  depth[k] = d;
  parent[0][k] = b;
  for (map<int, pair<int, int> >::iterator i = G[k].begin(); i != G[k].end();
       i++)
    if ((*i).first != b) {
      (*i).second.first = c;
      c++;
      c = dfs((*i).first, k, c, d + 1);
      (*i).second.second = c;
      c++;
    }
  return c;
}
void lcaInit() {
  for (int k = 1; k < 30; k++)
    for (int i = 1; i <= n; i++) {
      if (parent[k - 1][i] < 0)
        parent[k][i] = -1;
      else
        parent[k][i] = parent[k - 1][parent[k - 1][i]];
    }
}
int lca(int u, int v) {
  if (depth[u] > depth[v]) swap(u, v);
  for (int k = 0; k < 20; k++)
    if ((depth[v] - depth[u]) >> k & 1) {
      v = parent[k][v];
    }
  if (u == v) return u;
  for (int k = 28; 0 <= k; k--)
    if (parent[k][u] != parent[k][v]) {
      u = parent[k][u];
      v = parent[k][v];
    }
  return parent[0][u];
}
int edge[200000 * 2][2];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    G[a][b] = make_pair(-1, -1);
    G[b][a] = make_pair(-1, -1);
    edge[i + 1][0] = a;
    edge[i + 1][1] = b;
  }
  int N = dfs(1, -1, 0, 0) + 1;
  lcaInit();
  for (int i = 1; i <= n; i++)
    for (map<int, pair<int, int> >::iterator j = G[i].begin(); j != G[i].end();
         j++)
      if (-1 < (*j).second.first && -1 < (*j).second.second) {
        add((*j).second.first, (*j).second.first + 1, 1, 0, 0, N);
        add((*j).second.second, (*j).second.second + 1, -1, 0, 0, N);
      }
  int m;
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      int e, a, b;
      scanf("%d", &e);
      a = edge[e][0], b = edge[e][1];
      if (vdfs[a] > vdfs[b]) swap(a, b);
      add(G[a][b].first, G[a][b].first + 1, -(1 << 28), 0, 0, N);
      add(G[a][b].second, G[a][b].second + 1, (1 << 28), 0, 0, N);
      add(G[a][b].first, G[a][b].first + 1, 1, 0, 0, N);
      add(G[a][b].second, G[a][b].second + 1, -1, 0, 0, N);
    } else if (t == 2) {
      int e, a, b;
      scanf("%d", &e);
      a = edge[e][0], b = edge[e][1];
      if (vdfs[a] > vdfs[b]) swap(a, b);
      add(G[a][b].first, G[a][b].first + 1, -1, 0, 0, N);
      add(G[a][b].second, G[a][b].second + 1, 1, 0, 0, N);
      add(G[a][b].first, G[a][b].first + 1, (1 << 28), 0, 0, N);
      add(G[a][b].second, G[a][b].second + 1, -(1 << 28), 0, 0, N);
    } else {
      int a, b, c;
      scanf("%d%d", &a, &b);
      c = lca(a, b);
      long long res =
          sum(vdfs[c], vdfs[a], 0, 0, N) + sum(vdfs[c], vdfs[b], 0, 0, N);
      if ((1 << 28) / 2 < res) res = -1;
      cout << res << endl;
    }
  }
  return 0;
}
