Under construction

Still being built. Things may change

Meeting at the Agreed Minute

Time limit2sMemory limit512 MB

Summary
Count pairs of walks of length T from nodes 1 and N that meet only at minute T, modulo 9973.
Level

Medium7 of 10

Topics
Matrix, Dynamic programming, Graph
Solved
No attempts yet

Problem

Alice and Bob live in a city with NN intersections, numbered 1 through NN. The city has MM roads. Every road is bidirectional and joins two different intersections directly, and each pair of intersections is joined by at most one road.

Alice lives at intersection 1 and Bob lives at intersection NN. At noon they leave their houses and start wandering through the city. Every minute each of them moves from the intersection they are standing on to another intersection joined to it by a road. Staying in place is not allowed, so each of them moves exactly once per minute.

They agree to meet at some intersection exactly TT minutes after noon, and they do not want to run into each other before then. That is, at every minute from 0 to T−1T-1 the two stand at different intersections, and at minute TT they stand at the same intersection. They travel fast, so passing each other on one road in opposite directions does not count as running into each other.

Count the ways the two can move through the city. Two ways differ if Alice's sequence of intersections differs, or Bob's does.

Input

The first line contains an integer KK, the number of test cases (1≤K≤51 \le K \le 5). Then KK test cases follow in the format below.

The first line of each test case contains three integers NN, MM and TT (2≤N≤102 \le N \le 10, 1≤M≤501 \le M \le 50, 1≤T≤10121 \le T \le 10^{12}). Each of the next MM lines contains two integers AA and BB, meaning that a bidirectional road joins intersection AA and intersection BB (1≤A≤N1 \le A \le N, 1≤B≤N1 \le B \le N, A≠BA \ne B).

Output

For each test case, print on one line the number of ways Alice and Bob can move so that they stand at the same intersection at minute TT and never stand at the same intersection before then, modulo 9973.

Examples5

  1. Example 1

    Input
    4
    3 3 2
    1 2
    2 3
    1 3
    3 2 2
    1 2
    2 3
    4 4 10
    1 2
    2 4
    1 3
    4 3
    4 5 1000
    1 2
    2 4
    1 3
    4 3
    1 4
    
    Expected output
    3
    0
    1024
    3213
    
  2. Example 2

    Input
    2
    3 3 1
    1 2
    2 3
    1 3
    3 2 1
    1 2
    2 3
    
    Expected output
    1
    1
    
  3. Example 3

    Input
    3
    2 1 1
    1 2
    2 1 2
    1 2
    2 1 1000000000000
    1 2
    
    Expected output
    0
    0
    0
    
  4. Example 4

    Input
    4
    4 6 1
    1 2
    1 3
    1 4
    2 3
    2 4
    3 4
    4 6 2
    1 2
    1 3
    1 4
    2 3
    2 4
    3 4
    4 6 3
    1 2
    1 3
    1 4
    2 3
    2 4
    3 4
    4 6 1000000000000
    1 2
    1 3
    1 4
    2 3
    2 4
    3 4
    
    Expected output
    2
    14
    98
    5644
    
  5. Example 5

    Input
    2
    4 4 999999999999
    1 2
    2 4
    1 3
    4 3
    4 4 1000000000000
    1 2
    2 4
    1 3
    4 3
    
    Expected output
    3991
    7982