#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long w = 0, s = 1;
  char c = getchar();
  while (!isdigit(c)) {
    s = (c == '-') ? -1 : 1;
    c = getchar();
  }
  while (isdigit(c)) {
    w = (w << 3) + (w << 1) + c - '0';
    c = getchar();
  }
  return w * s;
}
const int N = 200005;
long long pre[N], cnt;
struct Edge {
  long long nxt, to, wei, from;
};
Edge edge[N << 1];
void add_for(long long u, long long v, long long w) {
  edge[++cnt].nxt = pre[u];
  edge[cnt].to = v;
  edge[cnt].wei = w;
  edge[cnt].from = u;
  pre[u] = cnt;
}
long long f[N][21], dep[N], fa[N], va[N];
long long find(long long x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
void search(long long u, long long grt) {
  f[u][0] = grt;
  dep[u] = dep[grt] + 1;
  for (long long i = 1; i <= 17; i++) {
    f[u][i] = f[f[u][i - 1]][i - 1];
  }
  for (long long i = pre[u]; i > 0; i = edge[i].nxt) {
    long long v = edge[i].to, w = edge[i].wei;
    if (v != grt) {
      if (w == 1) {
        fa[v] = find(u);
      }
      va[v] = w;
      search(v, u);
    }
  }
}
long long LCA(long long u, long long v) {
  if (dep[u] < dep[v]) {
    swap(u, v);
  }
  for (long long i = 17; i >= 0; i--) {
    if (dep[f[u][i]] >= dep[v]) {
      u = f[u][i];
    }
    if (u == v) {
      return u;
    }
  }
  for (long long i = 17; i >= 0; i--) {
    if (f[u][i] != f[v][i]) {
      u = f[u][i];
      v = f[v][i];
    }
  }
  return f[u][0];
}
long long n, q;
int main() {
  n = read();
  q = read();
  long long u, v, w;
  for (long long i = 1; i < n; i++) {
    u = read();
    v = read();
    w = read();
    add_for(u, v, w);
    add_for(v, u, w);
  }
  for (long long i = 1; i <= n; i++) {
    fa[i] = i;
  }
  search(1, 0);
  long long opt, x, y, z;
  for (long long p = 1; p <= q; p++) {
    opt = read();
    if (opt == 1) {
      x = read();
      y = read();
      z = read();
      long long anc = LCA(x, y), a = x, b = y;
      while (dep[a] > dep[anc] && z) {
        z /= va[a];
        a = find(f[a][0]);
      }
      while (dep[b] > dep[anc] && z) {
        z /= va[b];
        b = find(f[b][0]);
      }
      printf("%lld\n", z);
    } else {
      x = read();
      y = read();
      long long u = edge[x << 1].from, v = edge[x << 1].to;
      if (f[u][0] == v) {
        z = u;
      } else {
        z = v;
      }
      va[z] = y;
      if (va[z] == 1) {
        fa[z] = find(f[z][0]);
      }
    }
  }
  return 0;
}

### Prompt

Construct a CPP code solution to the problem outlined:

Bogdan has a birthday today and mom gave him a tree consisting of n vertecies. For every edge of the tree i, some number xi was written on it. In case you forget, a tree is a connected non-directed graph without cycles. After the present was granted, m guests consecutively come to Bogdan's party. When the i-th guest comes, he performs exactly one of the two possible operations: 

  1. Chooses some number yi, and two vertecies ai and bi. After that, he moves along the edges of the tree from vertex ai to vertex bi using the shortest path (of course, such a path is unique in the tree). Every time he moves along some edge j, he replaces his current number yi by <image>, that is, by the result of integer division yi div xj. 
  2. Chooses some edge pi and replaces the value written in it xpi by some positive integer ci < xpi. 



As Bogdan cares about his guests, he decided to ease the process. Write a program that performs all the operations requested by guests and outputs the resulting value yi for each i of the first type.

Input

The first line of the input contains integers, n and m (2 ≤ n ≤ 200 000, 1 ≤ m ≤ 200 000) — the number of vertecies in the tree granted to Bogdan by his mom and the number of guests that came to the party respectively.

Next n - 1 lines contain the description of the edges. The i-th of these lines contains three integers ui, vi and xi (1 ≤ ui, vi ≤ n, ui ≠ vi, 1 ≤ xi ≤ 1018), denoting an edge that connects vertecies ui and vi, with the number xi initially written on it.

The following m lines describe operations, requested by Bogdan's guests. Each description contains three or four integers and has one of the two possible forms: 

  * 1 ai bi yi corresponds to a guest, who chooses the operation of the first type. 
  * 2 pi ci corresponds to a guests, who chooses the operation of the second type. 

It is guaranteed that all the queries are correct, namely 1 ≤ ai, bi ≤ n, 1 ≤ pi ≤ n - 1, 1 ≤ yi ≤ 1018 and 1 ≤ ci < xpi, where xpi represents a number written on edge pi at this particular moment of time that is not necessarily equal to the initial value xpi, as some decreases may have already been applied to it. The edges are numbered from 1 to n - 1 in the order they appear in the input.

Output

For each guest who chooses the operation of the first type, print the result of processing the value yi through the path from ai to bi.

Examples

Input

6 6
1 2 1
1 3 7
1 4 4
2 5 5
2 6 2
1 4 6 17
2 3 2
1 4 6 17
1 5 5 20
2 4 1
1 5 1 3


Output

2
4
20
3


Input

5 4
1 2 7
1 3 3
3 4 2
3 5 5
1 4 2 100
1 5 4 1
2 2 2
1 1 3 4


Output

2
0
2

Note

Initially the tree looks like this: 

<image>

The response to the first query is: <image> = 2

After the third edge is changed, the tree looks like this: 

<image>

The response to the second query is: <image> = 4

In the third query the initial and final vertex coincide, that is, the answer will be the initial number 20.

After the change in the fourth edge the tree looks like this: 

<image>

In the last query the answer will be: <image> = 3

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long w = 0, s = 1;
  char c = getchar();
  while (!isdigit(c)) {
    s = (c == '-') ? -1 : 1;
    c = getchar();
  }
  while (isdigit(c)) {
    w = (w << 3) + (w << 1) + c - '0';
    c = getchar();
  }
  return w * s;
}
const int N = 200005;
long long pre[N], cnt;
struct Edge {
  long long nxt, to, wei, from;
};
Edge edge[N << 1];
void add_for(long long u, long long v, long long w) {
  edge[++cnt].nxt = pre[u];
  edge[cnt].to = v;
  edge[cnt].wei = w;
  edge[cnt].from = u;
  pre[u] = cnt;
}
long long f[N][21], dep[N], fa[N], va[N];
long long find(long long x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
void search(long long u, long long grt) {
  f[u][0] = grt;
  dep[u] = dep[grt] + 1;
  for (long long i = 1; i <= 17; i++) {
    f[u][i] = f[f[u][i - 1]][i - 1];
  }
  for (long long i = pre[u]; i > 0; i = edge[i].nxt) {
    long long v = edge[i].to, w = edge[i].wei;
    if (v != grt) {
      if (w == 1) {
        fa[v] = find(u);
      }
      va[v] = w;
      search(v, u);
    }
  }
}
long long LCA(long long u, long long v) {
  if (dep[u] < dep[v]) {
    swap(u, v);
  }
  for (long long i = 17; i >= 0; i--) {
    if (dep[f[u][i]] >= dep[v]) {
      u = f[u][i];
    }
    if (u == v) {
      return u;
    }
  }
  for (long long i = 17; i >= 0; i--) {
    if (f[u][i] != f[v][i]) {
      u = f[u][i];
      v = f[v][i];
    }
  }
  return f[u][0];
}
long long n, q;
int main() {
  n = read();
  q = read();
  long long u, v, w;
  for (long long i = 1; i < n; i++) {
    u = read();
    v = read();
    w = read();
    add_for(u, v, w);
    add_for(v, u, w);
  }
  for (long long i = 1; i <= n; i++) {
    fa[i] = i;
  }
  search(1, 0);
  long long opt, x, y, z;
  for (long long p = 1; p <= q; p++) {
    opt = read();
    if (opt == 1) {
      x = read();
      y = read();
      z = read();
      long long anc = LCA(x, y), a = x, b = y;
      while (dep[a] > dep[anc] && z) {
        z /= va[a];
        a = find(f[a][0]);
      }
      while (dep[b] > dep[anc] && z) {
        z /= va[b];
        b = find(f[b][0]);
      }
      printf("%lld\n", z);
    } else {
      x = read();
      y = read();
      long long u = edge[x << 1].from, v = edge[x << 1].to;
      if (f[u][0] == v) {
        z = u;
      } else {
        z = v;
      }
      va[z] = y;
      if (va[z] == 1) {
        fa[z] = find(f[z][0]);
      }
    }
  }
  return 0;
}

```