#P4645. [COCI 2006/2007 #3] BICIKLI
[COCI 2006/2007 #3] BICIKLI
Description
There are towns in this place, numbered from to , and there are directed roads connecting them. The race starts in town and ends in town .
The organizers want to know how many different routes there are in total.
Input Format
The first line contains two integers , with the meanings described above.
The next lines each contain two integers , describing a road from to .
There may be multiple roads between two towns.
Output Format
Output the number of different routes.
If there are infinitely many different routes, output inf.
Otherwise, output the result modulo .
6 7
1 3
1 4
3 2
4 2
5 6
6 5
3 4
3
6 8
1 3
1 4
3 2
4 2
5 6
6 5
3 4
4 3
inf
Hint
Constraints
For of the testdata, , .
Notes
Translated from COCI2006-2007 CONTEST #3 T5 BICIKLI.
Thanks to
https://www.luogu.com.cn/user/45475
ing the translation.
Translated by ChatGPT 5
京公网安备 11011102002149号