//itisalways42
#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
typedef pair<LL,LL> II;
typedef vector< II > VII;
typedef vector<int> VI;
typedef vector< VI > VVI;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N = int(1e5)+10;
const int LOGN = 20;
VII g[N],tree[N];
int Q[N],arr[N],dep[N],lev[N];
int Time,n;
LL initDist[N],currDist[N];
LL Bit[N],parEdge[N];
int Par[LOGN][N];
void add(int x, LL val)
{
while(x<N)
{
Bit[x] += val;
x += x&(-x);
}
}
LL query(int x)
{
LL ret=0;
while(x)
{
ret += Bit[x];
x -= x&(-x);
}
return ret;
}
void dfs0(int u=0, int p=0, LL d=0, int h=0)
{
Par[0][u] = p;
initDist[u] = d;
arr[u] = Time++;
lev[u] = h;
for(int i=0; i<SZ(g[u]); i++)
if(g[u][i].F != p)
{
parEdge[g[u][i].F] = g[u][i].S;
dfs0(g[u][i].F,u,d+g[u][i].S,h+1);
}
dep[u] = Time;
}
void precompute()
{
Time = 1;
dfs0();
for(int i=1; i<LOGN; i++)
for(int j=0; j<n; j++)
Par[i][j] = Par[i-1][Par[i-1][j]];
// arrange nodes in order of arrival time
vector<II> v;
for(int i=0; i<n; i++) v.PB(MP(arr[i],i));
sort(ALL(v));
// build Fenwick tree where sum upto index i is distance from node i-1 to node 0 (root)
add(1,initDist[v[0].S]);
for(int i=1; i<SZ(v); i++) add(i+1,initDist[v[i].S]-initDist[v[i-1].S]);
}
int lca(int u, int v)
{
if(lev[u] < lev[v]) swap(u,v);
for(int i=LOGN-1; i>=0; i--)
if(lev[Par[i][u]] >= lev[v])
u = Par[i][u];
if(u==v) return u;
for(int i=LOGN-1; i>=0; i--)
if(Par[i][u] != Par[i][v])
u = Par[i][u], v = Par[i][v];
return Par[0][u];
}
LL dist(int u, int p)
{
if(lev[u] < lev[p]) swap(u,p);
return currDist[u] - currDist[p];
}
//Q[]: array containing k nodes of auxillary tree
//arr[] : arrival time of nodes
//dep[] : departure time of nodes
//anc(p,u) : returns true if p is ancestor of u
//VI tree[N] : final auxillary tree with O(k) nodes
bool anc(int p, int u)
{
return arr[p] < arr[u] && dep[p] >= dep[u];
}
bool cmp(int u,int v)
{
return arr[u]<arr[v];
}
int create_tree(int k)
{
//return root of tree
set<int> S;
//get distinct nodes
for(int i=0;i<k;i++)S.insert(Q[i]);k=0;
for(auto it=S.begin();it!=S.end();it++)Q[k++]=*it;
sort(Q,Q+k,cmp);
int kk = k;
//distinct initial nodes, add lca of adjacent pairs
for(int i=0;i<kk-1;i++)
{
int x = lca(Q[i],Q[i+1]);
if(S.count(x)) continue;
Q[k++]=x;
S.insert(x);
}
sort(Q,Q+k,cmp);
//get latest distance from each node in set S to root
for(int i=0; i<k; i++) currDist[Q[i]] = query(arr[Q[i]]);
//clear tree vector of every node in auxillary tree
for(int i=0; i<k; i++) tree[Q[i]].clear();
stack<int> s;
//Q[0] is root of auxillary tree as it has min arrival time
s.push(Q[0]);
for(int i=1;i<k;i++)
{
// find parent of Q[i] in auxillary tree
while(!anc(s.top(),Q[i])) s.pop();
// add edge with currDist
LL d = dist(Q[i],s.top());
tree[s.top()].PB(MP(Q[i],d));
tree[Q[i]].PB(MP(s.top(),d));
s.push(Q[i]);
}
return Q[0];
}
void updateEdge(int u, int v, LL val)
{
if(anc(u,v)) swap(u,v);
// update edge from u to v where v = par(u) from parEdge[u] to val
// this edge affects distance of every node in subtree of u which is the range [arr[u],dep[u]]
// hence update Fenwick tree at arr[u] and dep[u]+1
LL diff = val - parEdge[u];
parEdge[u] = val;
add(arr[u],diff);
add(dep[u],-diff);
}
LL ans[N],d1[N],d2[N];
void dfs(int u, int p)
{
// d1[u] and d2[u] denote the farthest and 2nd farthest leafs in subtree of u through 2 different children
d1[u] = 0; d2[u] = 0;
for(int i=0; i<SZ(tree[u]); i++)
{
int v = tree[u][i].F;
LL w = tree[u][i].S;
if(v == p) continue;
dfs(v,u);
if(d1[v] + w > d1[u])
{
d2[u] = d1[u];
d1[u] = d1[v] + w;
}
else if(d1[v] + w > d2[u])
d2[u] = d1[v] + w;
}
}
void dfs1(int u, int p)
{
// d1[u] and d2[u] denote the farthest and 2nd farthest leafs in subtree of u through 2 different children
// when considering u as root of auxillary tree
ans[u] = d1[u];
for(int i=0; i<SZ(tree[u]); i++)
{
int v = tree[u][i].F;
LL w = tree[u][i].S;
LL val = d1[u];
II tmp = MP(d1[v],d2[v]);
if(v == p) continue;
if(w + d1[v] == val) val = d2[u];
val += w;
// now change root of auxillary to v
if(val > d1[v])
{
d2[v] = d1[v];
d1[v] = val;
}
else if(val > d2[v])
d2[v] = val;
dfs1(v,u);
// change root of auxillary tree back to u
d1[v] = tmp.F;
d2[v] = tmp.S;
}
}
int query_nodes[N];
int main()
{
fast_io;
cin>>n;
for(int i=0; i<n-1; i++)
{
int u,v,w;
cin>>u>>v>>w; u--; v--;
g[u].PB(MP(v,w));
g[v].PB(MP(u,w));
}
precompute();
int q; cin>>q;
while(q--)
{
int ty; cin>>ty;
if(ty == 1) // update edge
{
int u,v; LL w;
cin>>u>>v>>w; u--; v--;
updateEdge(u,v,w);
}
else // subset query
{
int k; cin>>k;
for(int i=0; i<k; i++) cin>>Q[i], Q[i]--;
for(int i=0; i<k; i++) query_nodes[i] = Q[i];
int root = create_tree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