#include <bits/stdc++.h>
using namespace std;
const long long inf = 2e18 + 7;
const long long mod = 1e9 + 7;
const double eps = 1e-9;
const double PI = 2 * acos(0.0);
const double E = 2.71828;
struct query {
  int d, t, c;
  friend bool operator<(query a, query b) {
    return a.d < b.d || (a.d == b.d && a.t < b.t) ||
           (a.d == b.d && a.t == b.t && a.c < b.c);
  }
};
int n, q;
vector<pair<int, int>> g[100005];
int number[100005];
int prv[100005];
int sz[100005];
int dist[100005];
set<query> second[100005];
int timer;
void dfs1(int v, int pr = -1) {
  sz[v] = 1;
  for (int i = 0; i < g[v].size(); ++i) {
    int to = g[v][i].first;
    if (to != pr && !number[to]) {
      dfs1(to, v);
      sz[v] += sz[to];
    }
  }
}
pair<int, int> dfs2(int v, int up, int ds, int pr = -1) {
  int all = up + 1;
  int mx = up;
  for (int i = 0; i < g[v].size(); ++i) {
    int to = g[v][i].first;
    int c = g[v][i].second;
    if (to != pr && !number[to]) {
      auto rs = dfs2(to, up + sz[v] - sz[to], ds + c, v);
      if (rs.first != -1) {
        return rs;
      }
      all += sz[to];
      mx = max(mx, sz[to]);
    }
  }
  if (mx <= all / 2) {
    return {v, ds};
  }
  return {-1, -1};
}
void build(int v, int cur_num, int ds, int par) {
  dfs1(v);
  pair<int, int> now = dfs2(v, 0, ds);
  int ver = now.first;
  number[ver] = cur_num;
  prv[ver] = par;
  if (par != -1) {
    dist[ver] = now.second;
  }
  for (int i = 0; i < g[ver].size(); ++i) {
    int to = g[ver][i].first;
    int c = g[ver][i].second;
    if (!number[to]) {
      build(to, cur_num + 1, c, ver);
    }
  }
}
void upd(int v, int d, int c) {
  while (v != -1) {
    while (!second[v].empty() && (*second[v].begin()).d <= d) {
      second[v].erase(second[v].begin());
    }
    second[v].insert({d, timer, c});
    d -= dist[v];
    if (d < 0) break;
    v = prv[v];
  }
}
int go(int v) {
  int rs = 0;
  int tm = -1;
  int d = 0;
  while (v != -1) {
    auto it = second[v].lower_bound({d, -1, -1});
    if (it != second[v].end() && (*it).t >= tm) {
      tm = (*it).t;
      rs = (*it).c;
    }
    d += dist[v];
    v = prv[v];
  }
  return rs;
}
int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; ++i) {
    int x, y, c;
    scanf("%d %d %d", &x, &y, &c);
    g[x].push_back({y, c});
    g[y].push_back({x, c});
  }
  build(1, 1, 0, -1);
  for (int i = 1; i <= n; ++i) {
  }
  scanf("%d", &q);
  for (timer = 0; timer < q; ++timer) {
    int t, v, d, c;
    scanf("%d %d", &t, &v);
    if (t == 1) {
      scanf("%d %d", &d, &c);
      upd(v, d, c);
    } else {
      printf("%d\n", go(v));
    }
  }
  return 0;
}
