#include <bits/stdc++.h>
using namespace std;
struct pos {
  int t, p;
};
struct tree {
  int size;
  vector<int> f;
};
int n, m;
vector<int> a[100001], no[100001];
vector<tree> tr;
pos v[100001], e[100000];
bool flag;
void ins(tree* w, int x, int y) {
  while (x <= (int)w->size) {
    w->f[x] += y;
    x += x & (-x);
  }
}
int sum(tree* w, int x) {
  int y = 0;
  while (x > 0) {
    y += w->f[x];
    x -= x & (-x);
  }
  return y;
}
void sol1() {
  int s = 1, i = 0, j = 0, k = 0;
  while ((s <= n) && ((int)a[s].size() > 1)) ++s;
  v[s].t = 0;
  v[s].p = 0;
  e[no[s][0]].t = 0;
  e[no[s][0]].p = 1;
  i = a[s][0];
  k = 1;
  for (int q = s; (int)a[i].size() > 1; ++k) {
    v[i].t = 0;
    v[i].p = k;
    j = 0;
    if (a[i][0] == q) j = 1;
    e[no[i][j]].t = 0;
    e[no[i][j]].p = k + 1;
    q = i;
    i = a[i][j];
  }
  v[i].t = 0;
  v[i].p = k;
  tree temp;
  temp.size = k;
  temp.f.resize(k + 1, 0);
  tr.push_back(temp);
  scanf("%d", &m);
  for (int q = 1; q <= m; ++q) {
    scanf("%d", &k);
    if (k == 1) {
      scanf("%d", &i);
      ins(&tr[e[i].t], e[i].p, -1);
    } else if (k == 2) {
      scanf("%d", &i);
      ins(&tr[e[i].t], e[i].p, 1);
    } else {
      scanf("%d %d", &i, &j);
      int d1 = sum(&tr[v[i].t], v[i].p), d2 = sum(&tr[v[j].t], v[j].p);
      if (abs(d1 - d2) == 0)
        printf("%d\n", abs(v[i].p - v[j].p));
      else
        printf("-1\n");
    }
  }
}
void soln(int s, int z) {
  int i = 0, j = 0, k = 0;
  v[s].t = 0;
  v[s].p = 0;
  for (int x = 0; x < z; ++x) {
    e[no[s][x]].t = x;
    e[no[s][x]].p = 1;
    i = a[s][x];
    k = 1;
    for (int q = s; (int)a[i].size() > 1; ++k) {
      v[i].t = x;
      v[i].p = k;
      j = 0;
      if (a[i][0] == q) j = 1;
      e[no[i][j]].t = x;
      e[no[i][j]].p = k + 1;
      q = i;
      i = a[i][j];
    }
    v[i].t = x;
    v[i].p = k;
    tree temp;
    temp.size = k;
    temp.f.resize(k + 1, 0);
    tr.push_back(temp);
  }
  scanf("%d", &m);
  for (int q = 1; q <= m; ++q) {
    scanf("%d", &k);
    if (k == 1) {
      scanf("%d", &i);
      ins(&tr[e[i].t], e[i].p, -1);
    } else if (k == 2) {
      scanf("%d", &i);
      ins(&tr[e[i].t], e[i].p, 1);
    } else {
      scanf("%d %d", &i, &j);
      int d1 = sum(&tr[v[i].t], v[i].p), d2 = sum(&tr[v[j].t], v[j].p);
      if (v[i].t == v[j].t) {
        if (abs(d1 - d2) == 0)
          printf("%d\n", abs(v[i].p - v[j].p));
        else
          printf("-1\n");
      } else {
        if (d1 + d2 == 0)
          printf("%d\n", v[i].p + v[j].p);
        else
          printf("-1\n");
      }
    }
  }
}
int main(void) {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    int j = 0, k = 0;
    scanf("%d %d", &j, &k);
    a[j].push_back(k);
    no[j].push_back(i);
    a[k].push_back(j);
    no[k].push_back(i);
  }
  flag = false;
  for (int i = 1; i <= n; ++i) {
    if ((int)a[i].size() > 2) {
      flag = true;
      soln(i, (int)a[i].size());
      break;
    }
  }
  if (!flag) sol1();
  return 0;
}
