// Slower C++ solution:
#include <stdio.h>

#include <iostream>

#include <vector>

using namespace std;

typedef long long ll;

 

vector<pair<int, ll> > path[100005];

int par[100005];

int dep[100005];

int siz[100005];

ll cst[100005];

int hev[100005];

void dfs(int a){

	siz[a]=1;

	for(int i=0; i<path[a].size(); i++){

		int d=path[a][i].first;

		if(d==par[a]) continue;

		par[d]=a;

		dep[d]=dep[a]+1;

		cst[d]=path[a][i].second;

		dfs(d);

		siz[a]+=siz[d];

		if(!hev[a] || siz[hev[a]]<siz[d])

			hev[a]=d;

	}

}

 

ll k;

ll add[100005];

ll edgecost(int a){

	ll ret=add[a]+add[par[a]]+cst[a];

	return ret%k?ret:0;

}

 

int pos[100005];

int hl_par[100005];

 

ll bit[100005];

ll sum(int i){

	ll ret=0;

	while(i){

		ret+=bit[i];

		i-=i&-i;

	}

	return ret;

}

void set(int i, ll x){

	// printf("set %d %lld\n", i, x);

	x-=sum(i+1)-sum(i);

	i++;

	while(i<100005){

		bit[i]+=x;

		i+=i&-i;

	}

}

 

int lca(int a, int b){

	int p=hl_par[a], q=hl_par[b];

	if(p==q) return dep[a]<dep[b]?a:b;

	if(dep[p]<dep[q]) return lca(a, par[q]);

	else return lca(par[p], b);

}

ll cost(int a){

	ll ret=0;

	while(a){

		int p=hl_par[a];

		ret+=sum(pos[a])-sum(pos[p]);

		if(p) ret+=edgecost(p);

		// printf("%d->%d:%lld %d->%d:%lld\n", a, p, sum(pos[a])-sum(pos[p]), p, par[p], edgecost(p));

		a=par[p];

	}

	return ret;

}

 

int main(){

	int n;

	cin >> n >> k;

	for(int i=0; i<n-1; i++){

		int a, b;

		ll c;

		cin >> a >> b >> c;

		path[a].push_back(make_pair(b, c));

		path[b].push_back(make_pair(a, c));

	}

	for(int i=0; i<n; i++) hev[i]=0;

	par[0]=dep[0]=cst[0]=0;

	dfs(0);

 

	for(int i=0; i<n; i++) add[i]=0;

 

	int cnt=0;

	for(int i=0; i<n; i++) pos[i]=-1;

	for(int i=0; i<n; i++){

		if(i && hev[par[i]]==i) continue;

		int j=i;

		do{

			// printf("%d ", j);

			pos[j]=cnt++;

			hl_par[j]=i;

		}while(j=hev[j]);

	}

	// printf("\n");



	for(int i=0; i<100005; i++) bit[i]=0;

	for(int i=0; i<n; i++)

		set(pos[i], edgecost(hev[i]));

	 

	int q;

	cin >> q;

	for(int i=0; i<q; i++){

		string s;

		ll a, b;

		cin >> s >> a >> b;

		if(s[0]=='a'){

			add[a]+=b;

			// for(int i=0; i<10; i++) printf("%lld ", sum(i)); printf("\n");

			set(pos[a], edgecost(hev[a]));

			if(a) set(pos[a]-1, edgecost(a));

			// for(int i=0; i<10; i++) printf("%lld ", sum(i)); printf("\n");

		}else{

			cout << (cost(a)+cost(b)-2*cost(lca(a, b))) << endl;

		}

	}

}

// Faster C++ solution for the same problem (measured speedup: 1.236003356505283x):
#include <stdio.h>

#include <iostream>

#include <vector>

using namespace std;

typedef long long ll;

 

#define N 112345

#define LO 18

class sbit{

public:

	ll bit[100005];

	ll sum(int i){

		ll ret=0;

		while(i){

			ret+=bit[i];

			i-=i&-i;

		}

		return ret;

	}

	void add(int i, ll x){

		i++;

		while(i<100005){

			bit[i]+=x;

			i+=i&-i;

		}

	}

	void add(int l, int r, ll x){

		add(l, x);

		add(r, -x);

	}

	ll get(int i){

		return sum(i+1);

	}

};



ll k;

vector<pair<int, ll> > path[100005];



int f[100005]; // original node index -> on the list

int c[100005]; // size of subtree

int d[100005]; // depth in tree

int p[100005][LO]; // parent doubling

// int dmm[N];

sbit csm, dsm, qry;



void dfs(int nw, int par, int dep, int ind){

	// printf("dfs(nw=%d, par=%d, dep=%d, ind=%d)\n", nw, par, dep, ind);

	f[nw]=ind;

	d[ind]=dep;

	p[ind][0]=par;

	for(int i=1; i<LO; i++)

	 	p[ind][i]=p[p[ind][i-1]][i-1];

	int sm=1;

	for(int i=0; i<path[nw].size(); i++){

		pair<int, ll> &pr=path[nw][i];

		if(f[pr.first]==par) continue;

		dfs(pr.first, ind, dep+1, ind+sm);

		csm.add(ind+sm, ind+sm+c[ind+sm], pr.second);

		if(pr.second%k==0){

			dsm.add(ind+sm, ind+sm+c[ind+sm], pr.second);

			// dmm[ind+sm]=pr.second;

		}

		sm+=c[ind+sm];

	}

	c[ind]=sm;

}



int lsc(int x, int y){

	if(d[x]<d[y]) swap(x, y);

	int dif=d[x]-d[y];

	for(int i=0; i<LO; i++)

	 	if(dif&(1<<i)) x=p[x][i];

	// printf(" %d %d\n", x, y);

	if(x==y) return x;

	int ret=0;

	for(int i=LO-1; i>=0; i--){

		// printf("(%d, %d)->(%d, %d)\n", x, y, p[x][i], p[y][i]);

		if(p[x][i]==p[y][i]) ret=p[x][i];

		else{

			x=p[x][i];

			y=p[y][i];

		}

	}

	return ret;

}



ll clc(int x){

	int q;

	while((q=qry.get(x))){

		int y=x;

		for(int i=LO-1; i>=0; i--){

			if(qry.get(p[y][i])==q) y=p[y][i];

		}

		dsm.add(y, y+c[y], -(dsm.get(y)-dsm.get(p[y][0])));

		ll r=csm.get(y)-csm.get(p[y][0]);

		if(r%k==0){

			dsm.add(y, y+c[y], r);

		}

		qry.add(y, y+c[y], -(qry.get(y)-qry.get(p[y][0])));

	}

	return csm.get(x)-dsm.get(x);

}



int main(){

	int n;

	cin >> n >> k;

	for(int i=0; i<n-1; i++){

		int a, b;

		ll c;

		cin >> a >> b >> c;

		path[a].push_back(make_pair(b, c));

		path[b].push_back(make_pair(a, c));

	}

	for(int i=0; i<n; i++) f[i]=-1;

	dfs(0, 0, 0, 0);



	int q;

	cin >> q;

	for(int i=0; i<q; i++){

		string s;

		ll x, y;

		cin >> s >> x >> y;

		if(s[0]=='a'){

			x=f[x];

			if(x){

			 	csm.add(x, x+c[x], y);

				qry.add(x, x+c[x], 1);

			}

			csm.add(x+1, x+c[x], y);

			qry.add(x+1, x+c[x], 1);

		}else{

			x=f[x];

			y=f[y];

			int z=lsc(x, y);

			ll ans=clc(x)+clc(y)-2*clc(z);

			cout << ans << endl;

		}

	}

}