#Lutece0585. k steps
k steps
Migrated from Lutece 585 k steps
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
Here are beautiful towns and m roads(directional edge). yjx wants to visit these towns for relaxation when he suddenly got a question. He wants to know the number of schemes to walk from town to town in exactly steps.A road can be visited more then once. It takes exactly one step to walk from one town to another if they are directly connected by a road.
yjx is very entangled with this matter, please help him.
Input
First line is a number , the number of the cases.
Each case is as follows:
First line includes four number: which means ()towns, ()roads, ()steps, and () lines test data.
Then there are lines, and each line is made up of two number (, ) which means one road from to .
Then l lines test data, and each line is made up of two number (so you must help yjx to know the number of the scheme that just walk steps from town to town ).
hint: maybe there are more than one road from to .
Output
For each test data, output the number of the scheme(the number is big, so you must make the number mod ).
Samples
2
2 2 1 2
1 2
2 1
1 2
2 1
3 2 2 1
1 2
2 3
1 3
1
1
1
Resources
Sichuan University Programming Contest