QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 64 MB Total points: 100

#14630. Cola

Statistics

The people of the planet Gallifrey are particularly fond of cola. Consequently, their enemies have developed a cola robot, which is placed in city $1$ of the planet Gallifrey. This cola robot has three types of behaviors: stay in place, move to an adjacent city, or self-destruct. Every second, it randomly triggers one of these behaviors. Now, given the map of the planet Gallifrey, how many possible behavioral sequences can the cola robot have at time $t$ if it starts in city $1$?

Input

The first line contains two integers $N$ and $M$, where $N$ represents the number of cities and $M$ represents the number of roads. ($1 \le N \le 30, 0 \le M \le 100$)

The next $M$ lines each contain two integers $u, v$, representing a road between $u$ and $v$. ($1 \le u, v \le n$) It is guaranteed that there is at most one road between any two cities.

The last line contains the time $t$.

Output

Output the number of behavioral sequences for the cola robot. Since the answer may be very large, output the result modulo $2017$.

Examples

Input 1

3 2
1 2
2 3
2

Output 1

8

Note

Example explanation: $1 \to$ self-destruct $1 \to 1 \to$ self-destruct $1 \to 2 \to$ self-destruct $1 \to 1 \to 1$ $1 \to 1 \to 2$ $1 \to 2 \to 1$ $1 \to 2 \to 2$ $1 \to 2 \to 3$

Constraints

For $20\%$ of the data, $1 < t \le 1000$. For $100\%$ of the data, $1 < t \le 10^6$.

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.