题目描述
Problem Description
You and Takahashi live in the AtCoder Kingdom. The AtCoder Kingdom has $ N $ towns and $ M $ roads connecting these towns, allowing bidirectional movement. The $ N $ towns are named Town $ 1 $, Town $ 2 $, ..., Town $ N $. The $ M $ roads are named Road $ 1 $, Road $ 2 $, ..., Road $ M $.
Takahashi decided to visit your house. He started from Town $ a $ and arrived at your house in Town $ b $ via some towns (possibly zero).
Takahashi claims he took the shortest path. Since Takahashi is honest, he never lies.
You decided to count how many shortest paths there are from Town $ a $ to Town $ b $. Since the answer can be very large, output the answer modulo $ 1,000,000,007 (=10^9+7) $.
A shortest path from Town $ a $ to Town $ b $ is defined as a path that minimizes the number of roads traversed from Town $ a $ to Town $ b $.
Input Format
The input is given from the standard input in the following format:
$ N $ $ a $ $ b $ $ M $ $ x_1 $ $ y_1 $ $ x_2 $ $ y_2 $ : $ x_M $ $ y_M $
- The first line contains an integer $ N(2≦N≦100) $, representing the number of towns in the AtCoder Kingdom.
- The second line contains two integers $ a,b(1≦a,b≦N,a≠b) $, representing the town where Takahashi starts and the town where your house is, separated by spaces.
- The third line contains an integer $ M(1≦M≦200) $, representing the number of roads in the AtCoder Kingdom.
- The next $ M $ lines contain the road information. The $ i(1≦i≦M) $-th line contains two integers $ x_i,y_i(1≦x_i,y_i≦N,x_i≠y_i) $, representing the towns connected by Road $ i $, separated by spaces.
- It is guaranteed that any town can be reached from any other town by traversing some roads.
Output Format
Output the number of shortest paths from Town $ a $ to Town $ b $ modulo $ 1,000,000,007 $ in one line.
Do not forget the newline at the end.
Sample Input and Output
Sample Input #1
7
1 7
8
1 2
1 3
4 2
4 3
4 5
4 6
7 5
7 6
Sample Output #1
4
Sample Input #2
7
1 7
9
1 2
1 3
4 2
4 3
4 5
4 6
7 5
7 6
4 7
Sample Output #2
2
Notes/Hints
Sample Explanation 1
For this input example, the following $ 4 $ shortest paths are possible:
- $ 1→2→4→5→7 $
- $ 1→3→4→5→7 $
- $ 1→2→4→6→7 $
- $ 1→3→4→6→7 $
Sample Explanation 2
For this input example, refer to the provided diagram.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分