Universal Cup Judging System

Universal Cup

Limite de temps : 4 s Limite de mémoire : 1024 MB Points totaux : 100 Difficulté: [afficher]
Statistiques

Description

Una and Kamome plan to go hiking in the suburb of Guangzhou.

There are $n$ views from west to east in the mountain, numbered from $1$ to $n$. The $i$-th view has an altitude $h_i$. Una decides to choose an interval $[l, r]$ ($1 \le l \le r \le n$) and travel from the $l$-th view to the $r$-th view.

However, Una dislikes valleys, so she doesn't want any $l < i < r$ to be a valley, that is, $h_{i-1} > h_i < h_{i+1}$. At the same time, she thinks that flat roads are boring, so she hopes that for all $l \le i < r$, $h_i \neq h_{i+1}$. Una will enjoy the trip if the interval $[l, r]$ satisfies these two conditions.

Kamome made some research before the hiking trip and found out the altitudes of some of the views. She wants to know that if the altitudes of all the other views are independent random integers in $[1, m]$, how many different intervals $[l, r]$ can be chosen to help Una enjoy the trip. Help Kamome find the expected value, modulo $10^9 + 7$.

Input

Each test contains multiple test cases. The first line contains one integer $t$ ($1 \le t \le 10^5$), indicating the number of test cases. The description of the test cases follows.

The first line contains two integers $n, m$ ($1 \le n \le 10^6$, $\sum n \le 10^7$, $1 \le m \le 10^9$), indicating the number of views in the mountain and the altitude range.

The second line contains $n$ integers $h_1, h_2, \dots, h_n$ ($1 \le h_i \le m$ or $h_i = -1$), indicating the result of the research Kamome made. If $h_i \neq -1$, $h_i$ means the actual altitude of view $i$. Otherwise, it means that Kamome didn't find any information about the altitude of view $i$ and regards it as a random integer in $[1, m]$.

Output

For each test case, print one integer, indicating the expected number of intervals $[l, r]$ such that Una enjoys the trip, modulo $10^9 + 7$.

Examples

input1

10
4 4
1 4 2 3
3 3
-1 2 -1
4 2
-1 -1 -1 1
4 3
1 -1 -1 3
5 5
-1 2 -1 4 -1
6 4
2 -1 1 -1 -1 1
5 5
1 -1 4 -1 1
8 4
-1 2 -1 -1 2 -1 4 -1
9 7
4 -1 2 -1 -1 6 -1 4 -1
20 20
-1 -1 -1 5 -1 -1 13 -1 10 -1 -1 -1 -1 12 -1 3 -1 -1 -1 18

output1

8
666666676
875000012
555555566
872000016
750000017
400000014
554687520
973046972
216066617

Note

For the first test case, Una enjoys the trip if she chooses intervals $[1, 1], [2, 2], [3, 3], [4, 4], [1, 2], [2, 3], [3, 4]$ or $[1, 3]$.

For the second test case, the answer is $\frac{14}{3}$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.