Master Zhu and Rikka

아직 제출이 없습니다시간 제한3초메모리 제한512 MB

문제

As we all know, Master Zhu is the most powerful man in the universe. He has infinite power to protect the world.

A magical rooted tree grows in Master Zhu's garden. The tree contains nn vertices and n1n - 1 edges. The root of the tree is in vertex 11. Each vertex ii contains an amount of Zhu power equal to a_ia\_i.

Little Rikka is a curious girl: she has mm questions to ask to Master Zhu. But now Master Zhu is busy protecting our world, so he wants you to help him answer Rikka's questions.

Each Rikka's question has the format "tt uu vv aa bb". 

  • If tt is 11, then uu is equal to vv, and Rikka looks at the subtree rooted in vertex uu and wants to know the GCD (greatest common divisor) of S_aS\_a and S_bS\_b, where S_aS\_a is the sum of numbers that appear exactly aa times in this subtree, and S_bS\_b is the sum of numbers that appear exactly bb times in this subtree.
  • If tt is 22, Rikka looks at the simple path between vertices uu and vv and wants to know the GCD of T_aT\_a and T_bT\_b, where T_aT\_a is the sum of numbers that appear exactly aa times on this path, and T_bT\_b is the sum of numbers that appear exactly bb times on this path.

Here, for any xx, we define GCD(x,0)=GCD(0,x)=x\mathrm{GCD} (x, 0) = \mathrm{GCD} (0, x) = x.

입력

The first line of input contains an integer TT, the number of test cases (1T101 \le T \le 10).

The first line of each test case contains two integers nn and mm: the number of vertices in the magical tree and the number of Rikka's questions (1n,m1051 \le n, m \le 10^5).

The next line contains nn integers a_1a\_1, a_2a\_2, \ldots, a_na\_n: the amount of Zhu power in each vertex (1a_i1091 \le a\_i \le 10^9).

Each of the next n1n - 1 lines contains two integers uu and vv and denotes an edge connecting vertices uu and vv (1u,vn1 \le u, v \le n). It is guaranteed that together, these edges form a tree.

Each of the next mm lines contains one of Rikka's questions in the format described above (1u,vn1 \le u, v \le n, 1a,bn1 \le a, b \le n).

출력

For each Rikka's question, print the answer on a separate line.