The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 6 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
Â
Utkarsh has come to a new country having N cities(numbered from 1to N). There are M directed roads in the country each of length 1 unit. Utkarsh is very lazy so he cannot walk more thanK units.
Â
He has Q queries. Each query is of the form a b. For each query he wants to know how many different paths (of positive length) are there from city a to b which Utkarsh can walk.
Â
Output the answer modulo 10^9+7.
Â
Â
First line contains N,M,K
next line contains M pairs a b denoting a directed road from a to b.
Next line contains Q.
Then Q pairs follow.
Â
Â
For each pair, print the answer to the problem modulo 10^9+7.
Â
Â
Â
Â
Input
3 4 2 1 1 2 2 3 3 1 1 1 1 1 Output
6
Â
Â
Input
3 5 3 1 1 1 2 2 2 2 3 3 3 2 1 3 2 3 Output
4 6
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll