F. Ursa Minor

Memory limit: 256 MiB Time limit: 1500 ms Input file: stdin Output file: stdout
Problem type: traditional Judging mode: text compare

Description

1

小熊座是一個坐落於北半球星空的星座。與北斗七星類似,小熊座一共有七顆星星,形成了勺子一樣的結構。

勾陳一,又稱為小熊座 \alpha ,是小熊座中最明亮的星星,同時也是現在天空的北極星.

給你一個 n 個點 m 條邊的無向圖,每個點代表一顆星星,保證無向圖不存在自環或重邊。點的編號為 1\sim n ,其中勾陳一是第 S 個點。

小明想找出這個圖裡有多少種情況可以形成小熊座那樣的結構(選擇另外六個點與 S 號點形成圖片中的子圖)。但這個問題太難了,於是他稍加了一點限制:

具體地,小明想要找到有多少個有序六元組 (a_1,a_2,a_3,a_4,a_5,a_6) 滿足:

  • 在無向圖中存在邊 (a_1,a_2),(a_2,a_3),(a_3,a_4),(a_4,a_1),(a_4,a_5),(a_5,a_6) (a_6,S)
  • 對於所有的 i=1,2,3,4,5 ,圖中不存在 (a_i,S)
  • 對於所有的 i=1,2,3,4,5,6 ,滿足 a_i\neq S
  • 對於所有的 1\le i < j \le 6 ,滿足 a_i\neq a_j

答案可能很大,你只需要輸出答案對 10^9+7 取模後的結果。


Ursa Minor, also known as the Little Bear, is a constellation located in the far northern sky. There are seven stars in the Little Bear, with four of them in its bowl, like Big Dipper.

Polaris, the brightest one in the constellation, is also known as North Star.

You are given an undirected graph with n stars and m edges. It is guaranteed that the graph has no self-circle or multiple edges. The stars are numbered from 1 to n , and Polaris is the S -th star.

Alice wants to count the number of Ursa Minors in this graph(pick out another six stars and form a subgraph just like the above picture). But that is too hard for her, so she adds a single constraint:

Specifically, she wants to find out how many tuples (a_1,a_2,a_3,a_4,a_5,a_6) of six different stars such that:

  • the graph contains edges (a_1,a_2),(a_2,a_3),(a_3,a_4),(a_4,a_1),(a_4,a_5),(a_5,a_6) and (a_6,S) .
  • the graph does not contain edges (a_i,S) for all i = 1,2,3,4,5 .
  • a_i\neq S for all i=1,2,3,4,5,6 .
  • a_i\neq a_j for all 1\le i < j\le 6 .

Since the answer may be large, print the answer modulo 10^9+7 .

Input

第一行一個整數 T ,表示數組組數。

對於每組數據:

第一行三個整數 n,m ,分別表示星星的個數、邊數與勾陳一的編號。

接下來 m 行,其中每行兩個整數 x,y ,表示圖中的一條邊。數據保證不存在重邊或自環。


The first line contains a single integer T , denoting the number of test cases.

For each test case:

The first line contains three integers n,m,s , denoting the number of stars, the number of edges and the index of Polaris respectively.

For the next m lines, each line contains two integers x,y , denoting an edge in the graph. It is guaranteed that 1\le x, y\le n and the graph has no self-circle or multiple edges.

Output

對於每組數據,輸出答案對 10^9+7 取模後的結果。


For each test case, print a single integer denoting the answer modulo 10^9+7 .

Sample

Sample input

2
7 7 7
1 2
2 3
3 4
4 1
4 5
5 6
6 7
10 15 7
1 2
2 3
3 4
1 4
4 5
5 6
6 7
5 8
7 8
9 4
9 5
9 8
10 4
10 5
10 8

Sample output

1
4

Constraint and hint

對於全部測試數據,滿足 1\le T\le 10^5, 1\le n \le 10^5, 0\le m \le \min(\frac{n(n-1)}{2},10^5),\sum n \le 10^5,\sum m \le 10^5

子任務 分數 附加限制
1 10 T=1, n\le 20
2 \sum n\le 40
3 15 \sum n\le 100
4 \sum n\le 300
5 20 \sum n\le 5000
6 30 無附加限制

It is guaranteed that 1\le T\le 10^5, 1\le n \le 10^5, 0\le m \le \min(\frac{n(n-1)}{2},10^5),\sum n \le 10^5,\sum m \le 10^5 .

Subtask Score Additional Constraints
1 10 T=1, n\le 20
2 \sum n\le 40
3 15 \sum n\le 100
4 \sum n\le 300
5 20 \sum n\le 5000
6 30 No additional constraints