Likely Landmark

Points: 1
Time limit: 1.0s
Memory limit: 256M

Author:
Problem types
Allowed languages
C, C++, Haskell, Java, Python

Alea is looking for Tors, Alea's cat.

Alea knows which landmark Tors was at during hour 0, and that at each hour Tors has an equal chance of walking to a neighboring landmark.

Landmarks are neighbors of themselves and, for any two landmarks $$a,b$$, if landmark $$a$$ is a neighbor of landmark $$b$$, then landmark $$b$$ is a neighbor of landmark $$a$$.

Alea is trying to work out, for each landmark, the likelihood of Tors being at that landmark at hour $$h$$.

As Alea is out looking for Tors, Alea has gotten you to determine how many walks, or sequences of landmarks allowing repetition, Tors could have taken to reach a given landmark $$f$$ at the hour $$h$$.

Input Specification

The first line contains two integers: The number of landmarks, $$n$$ $$(1 \leq n \leq 100)$$, Tors could visit; and the number of connections between landmarks $$e$$ $$(0 \leq e < 5000)$$. Each landmark is numbered 0 to n-1.

The second line contains three integers: The landmark Tors was at during hour 0, $$s$$ $$(0 \leq s < n)$$; the current hour, $$h$$ $$(1 \leq h \leq 100)$$; and the given landmark Alea is considering $$f$$ $$(0 \leq f < n)$$.

$$e$$ lines follow, each consisting of of two integers $$u$$,$$v$$ $$(0 \leq u,v < n)$$, where $$u$$ and $$v$$ are neighboring landmarks.

Output Specification

The number of walks Tors could have taken to reach landmark $$f$$ at the hour $$h$$ modulo $$10^{9}+7$$.

Sample Input 1

1 0
0 100 0

Sample Output 1

1

Sample Input 2

3 2
0 4 0
0 1
1 2

Sample Output 2

9

Sample Input 3

3 2
0 4 1
0 1
1 2

Sample Output 3

12