Join The Future

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

문제

Professor Zhang has an array of nn integers. He writes down some observations about the array on the paper. Each observation is described by three integers l_il\_i, r_ir\_i and s_is\_i, which means that the sum of elements modulo 2 on interval \[l_i,r_i]\[l\_i, r\_i] of the array is equal to s_is\_i.

After that, he tries to recover the array only using the above observations. Apparently, there are many such arrays. So, Professor Zhang decides to limit the lower bound and upper bound of each integer in the array.

Given the observations, the lower bounds and the upper bounds, find the number of possible arrays and the lexicographically smallest array.

입력

There are multiple test cases. The first line of input contains an integer TT indicating the number of test cases. For each test case:

The first line contains two integers nn and mm (1n401 \le n \le 40, 0mn(n+1)20 \le m \le \frac{n \cdot (n + 1)}{2}): the length of the array and the number of observations.

Each of the next nn lines contains two integers x_ix\_i and y_iy\_i (0x_iy_i1090 \le x\_i \le y\_i \le 10^9): the lower bound and upper bound of the ii-th integer.

Each of the next mm lines contains three integers l_il\_i, r_ir\_i and s_is\_i (1l_ir_in1 \le l\_i \le r\_i \le n, 0s_i10 \le s\_i \le 1) denoting the ii-th observation.

There are at most 110110 test cases, and the total size of the input is at most 3030 kibibytes.

출력

For each test case, output the number of possible arrays on the first line. As the value could be very large, print it modulo 109+710^9 + 7. Then, output the lexicographically smallest array on the second line. If the number of possible arrays equals to zero, just output "1-1" (without the quotes) in the second line.