Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

The problem statement has recently been changed. View the changes.

×
D. Happy Tree Party

time limit per test

3 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputBogdan has a birthday today and mom gave him a tree consisting of *n* vertecies. For every edge of the tree *i*, some number *x*_{i} 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:

- Chooses some number
*y*_{i}, and two vertecies*a*_{i}and*b*_{i}. After that, he moves along the edges of the tree from vertex*a*_{i}to vertex*b*_{i}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*y*_{i}by , that is, by the result of integer division*y*_{i}div*x*_{j}. - Chooses some edge
*p*_{i}and replaces the value written in it*x*_{pi}by some positive integer*c*_{i}<*x*_{pi}.

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 *y*_{i} 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 *u*_{i}, *v*_{i} and *x*_{i} (1 ≤ *u*_{i}, *v*_{i} ≤ *n*, *u*_{i} ≠ *v*_{i}, 1 ≤ *x*_{i} ≤ 10^{18}), denoting an edge that connects vertecies *u*_{i} and *v*_{i}, with the number *x*_{i} 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
*a*_{i}*b*_{i}*y*_{i}corresponds to a guest, who chooses the operation of the first type. - 2
*p*_{i}*c*_{i}corresponds to a guests, who chooses the operation of the second type.

Output

For each guest who chooses the operation of the first type, print the result of processing the value *y*_{i} through the path from *a*_{i} to *b*_{i}.

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:

The response to the first query is: = 2

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

The response to the second query is: = 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:

In the last query the answer will be: = 3

Codeforces (c) Copyright 2010-2022 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: May/23/2022 02:59:03 (k2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|