#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

template <typename S>
struct sparseTable {
    using T = typename S::T;
    int n;
    vector<int> log2;
    vector<vector<T>> t;

    sparseTable() {}
    sparseTable(int nn) { construct(nn); }
    void construct(int nn) {
        n = nn;
        log2.assign(n+1, 0);
        for(int i=2; i<=n; ++i) log2[i] = log2[i >> 1] + 1;
        t = vector<vector<T>>(log2[n]+1, vector<T>(n));
    }
    void init(vector<T> v) {
        for(int i=0; i<n; ++i) t[0][i] = v[i];
        for(int j=1; j<=log2[n]; ++j) {
            int w = 1LL<<(j-1);
            for (int i = 0; i+(w<<1) <= n; ++i) {
                t[j][i] = S::op(t[j-1][i], t[j-1][i+w]);
            }
        }
    }
    // [l, r]
    T query(int l, int r) {
        int j = log2[r - l];
        return S::op(t[j][l], t[j][r-(1 << j)+1]);
    }
};

class LCA {
private:
    const int n = 0;
    const int log2_n = 0;
    vector<vector<int>> par;
    vector<vector<int>> g;
    vector<int> depth;     // 頂点iの深さ
    vector<int> vs;        // 頂点を訪問順に並べたもの
    vector<int> depth_seq; // depth_seq[i] = (頂点vs[i]の深さ)
    vector<int> id;        // 頂点が初めてvsに登場するインデックス
    struct minimum_st {
        using T = PII;
        static T op(const T& a, const T& b) { return min(a, b); }
    }; 
    sparseTable<minimum_st> st;
    void dfs(int v, int p, int d, int &k) {
        id[v] = k; vs[k] = v; depth_seq[k++] = d; depth[v] = d;
        for(auto to: g[v]) if(to != p) {
            dfs(to, v, d+1, k);
            vs[k] = v; depth_seq[k++] = d;
        }
    }
public:
    LCA(int n_=1e5) : n(n_), g(n), depth(n), vs(2*n-1), depth_seq(2*n-1), id(n) {}
    // u-vに辺を張る
    void add_edge(int u, int v) {
        g[u].push_back(v);
        g[v].push_back(u);
    }
    // rootを根として初期化
    void build(int root = 0) {
        int k = 0;
        dfs(root, -1, 0, k);
        vector<PII> v(2*n-1);
        REP(i, 2*n-1) v[i] = {depth_seq[i], i};
        st.construct(2*n-1);
        st.init(v);
    }
    // uとvのlcaを返す O(1)
    int get(int u, int v) {
        if(id[u] > id[v]) swap(u, v);
        return vs[st.query(id[u], id[v]).second];
    }
};

int main(void) {
    ll n;
    cin >> n;
    vector<vector<PII>> g(n);
    LCA lca(n);
    REP(i, n-1) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        g[a].emplace_back(b, c);
        g[b].emplace_back(a, c);
        lca.add_edge(a, b);
    }
    lca.build();

    vector<ll> sz(n), dead(n);
    auto find_centroid = [&](ll root) {
        auto get_size = [&](auto &&self, ll v, ll p) -> void {
            sz[v] = 1;
            for(auto to: g[v]) if(to.first != p && !dead[to.first]) {
                self(self, to.first, v);
                sz[v] += sz[to.first];
            }
        };
        get_size(get_size, root, -1);
        auto dfs = [&](auto &&self, ll v, ll p) -> ll {
            for(auto to: g[v]) if(to.first != p && !dead[to.first]) {
                if(sz[to.first] > sz[root]/2) return self(self, to.first, v);
            }
            return v;
        };
        return dfs(dfs, root, -1);
    };

    vector<ll> par(n);
    auto centroid_decomposition = [&](auto &&self, ll root, ll p) -> void {
        ll c = find_centroid(root);
        dead[c] = true;
        par[c] = p;
        for(auto to: g[c]) if(!dead[to.first]) {
            self(self, to.first, c);
        }
        dead[c] = false;
    };
    centroid_decomposition(centroid_decomposition, 0, -1);

    vector<ll> depth(n);
    auto get_depth = [&](auto &&self, ll v, ll p, ll d) -> void {
        depth[v] = d;
        for(auto to: g[v]) if(to.first!=p) {
            self(self, to.first, v, d+to.second);
        }
    };
    get_depth(get_depth, 0, -1, 0);
    auto distance = [&](ll u, ll v) {
        return depth[u] + depth[v] - 2*depth[lca.get(u,v)];
    };

    using P = pair<ll,PII>;
    vector<vector<P>> info(n);
    ll q;
    cin >> q;
    REP(i, q) {
        ll type, v;
        cin >> type >> v;
        v--;
        if(type == 1) {
            ll d, c;
            cin >> d >> c;
            ll u = v;
            while(u != -1) {
                ll dist = d - distance(u, v);
                if(dist < 0) {
                    u = par[u];
                    continue;
                }
                while(info[u].size() && info[u].rbegin()->first <= dist) info[u].pop_back();
                info[u].push_back({dist, {i, c}});
                u = par[u];
            }
        } else {
            ll u = v;
            PII ret({-1, 0});
            if(i == q/2) dump(info[u].size());
            while(u != -1) {
                ll dist = distance(u, v);
                for(auto j: info[u]) {
                    if(j.first < dist) break;
                    chmax(ret, j.second);
                }
                u = par[u];
            }
            cout << ret.second << "\n";
        }
    }

    return 0;
}