#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<stack>
#include<cstring>
#include<set>
#include<iterator>
#include<list>
#include<deque>
#include<queue>
#include<map>
#include<cmath>
#include<sstream>
#include<cstdio>
#include<stdio.h>
#include<string.h>
using namespace std;
typedef long long ll;
const int N = 1E5 + 5;
int head[N], ver[2 * N], edge[2 * N], Next[2 * N], tot;
int top[N];
int deep[N];
int num[N];
int p[N];
int fp[N];
int fa[N];
int son[N];
int pos = 1;
void init()
{
pos = 1;
tot = 0;
memset(head, 0, sizeof(head));
memset(son, -1, sizeof(son));
}
void add(int a, int b,int c)
{
edge[++tot] = c, ver[tot] = b, Next[tot] = head[a], head[a] = tot;
edge[++tot] = c, ver[tot] = a, Next[tot] = head[b], head[b] = tot;
}
void dfs1(int u, int pre, int d)
{
deep[u] = d;
fa[u] = pre;
num[u] = 1;
for (int i = head[u]; i; i = Next[i])
{
int v = ver[i];
if (v != pre)
{
dfs1(v, u, d + 1);
num[u] += num[v];
if (son[u] == -1 || num[v] > num[son[u]])
{
son[u] = v;
}
}
}
}
void getpos(int u, int sp)
{
top[u] = sp;
p[u] = pos++;
fp[p[u]] = u;
if (son[u] == -1)
return;
getpos(son[u], sp);
for (int i = head[u]; i; i = Next[i])
{
int v = ver[i];
if (v != son[u] && v != fa[u])
{
getpos(v, v);
}
}
}
int lowbit(int x)
{
return x & (-x);
}
int c[N];
int n, q, s;
int sum(int i)
{
int s = 0;
while (i > 0)
{
s += c[i];
i -= lowbit(i);
}
return s;
}
void update(int i, int val)
{
while(i <= n)
{
c[i] += val;
i += lowbit(i);
}
}
void Query(int u, int v)
{
int f1 = top[u], f2 = top[v];
int tmp = 0;
while (f1 != f2)
{
if (deep[f1] < deep[f2])
{
swap(f1, f2);
swap(u, v);
}
tmp += sum(p[u]) - sum(p[f1] - 1);
u = fa[f1];
f1 = top[u];
}
if (deep[u] > deep[v])
swap(u, v);
tmp += sum(p[v]) - sum(p[u]);
cout << tmp << endl;
}
int e[N][3];
int main()
{
//ios::sync_with_stdio(false);
//cin.tie(0), cout.tie(0);
cin >> n >> q >> s;
init();
memset(c, 0, sizeof(c));
for (int i = 1; i < n; i++)
{
scanf("%d%d%d", &e[i][0], &e[i][1], &e[i][2]);
//cin >> e[i][0] >> e[i][1] >> e[i][2];
add(e[i][0], e[i][1], e[i][2]);
}
dfs1(1, 0, 0);
getpos(1, 1);
for (int i = 1; i < n; i++)
{
if (deep[e[i][0]] > deep[e[i][1]])
swap(e[i][0], e[i][1]);
update(p[e[i][1]], e[i][2]);
}
while (q--)
{
int x;
//cin >> x;
scanf("%d", &x);
if (x == 1)
{
int i, w;
//cin >> i >> w;
scanf("%d%d", &i, &w);
update(p[e[i][1]], w - e[i][2]);
e[i][2] = w;
}
else
{
int x;
//cin >> x;
scanf("%d", &x);
Query(s, x);
s = x;
}
}
return 0;
}