#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 nn 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 AA to town BB in exactly kk 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 TT, the number of the cases.

Each case is as follows:

First line includes four number: n,m,k,ln, m, k, l which means nn(1n1001 \leq n \leq 100)towns, mm(1m10001 \leq m \leq 1000)roads, kk(1k10001\leq k\leq 1000)steps, and ll (1l10001\leq l\leq 1000) lines test data.

Then there are mm lines, and each line is made up of two number u,vu, v (uvu \neq v, 1u,vn1\leq u,v \leq n) which means one road from uu to vv.

Then l lines test data, and each line is made up of two number p,qp, q (so you must help yjx to know the number of the scheme that just walk kk steps from town pp to town qq).

hint: maybe there are more than one road from uu to vv .

Output

For each test data, output the number of the scheme(the number is big, so you must make the number mod 19911991).

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