#3207. Master of GCD

Master of GCD

Problem Description

Hakase has nn numbers in a line. At first, they are all equal to 11. Besides, Hakase is interested in primes. She will choose a continuous subsequence [l,r][l,r] and a prime parameter xx each time and for every lirl≤i≤r, she will change aia_i into ai×xa_i×x. To simplify the problem, xx will be 22 or 33. After mm operations, Hakase wants to know what is the greatest common divisor of all the numbers.

Input

The first line contains an integer T(1T10)T(1≤T≤10) representing the number of test cases.

For each test case, the first line contains two integers n(1n100000)n(1≤n≤100000) and m(1m100000)m(1≤m≤100000), where nn refers to the length of the whole sequence and mm means there are mm operations.

The following mm lines, each line contains three integers li(1lin),ri(1rin),xi(xi2,3)l_i(1≤l_i≤n),r_i(1≤r_i≤n),x_i(x_i∈2,3), which are referred above.

Output

For each test case, print an integer in one line, representing the greatest common divisor of the sequence. Due to the answer might be very large, print the answer modulo 998244353998244353.

Sample

2
5 3
1 3 2
3 5 2
1 5 3
6 3
1 2 2 
5 6 2 
1 6 2
6
2

Hint

For the first test case, after all operations, the numbers will be [6,6,12,6,6][6,6,12,6,6]. So the greatest common divisor is 66.