#P4645. [COCI 2006/2007 #3] BICIKLI

    ID: 3616 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>2006广度优先搜索,BFS强连通分量,缩点概率论,统计COCI

[COCI 2006/2007 #3] BICIKLI

Description

There are nn towns in this place, numbered from 11 to nn, and there are mm directed roads connecting them. The race starts in town 11 and ends in town 22.

The organizers want to know how many different routes there are in total.

Input Format

The first line contains two integers n,mn, m, with the meanings described above.

The next mm lines each contain two integers a,ba, b, describing a road from aa to bb.

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 10910^9.

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 100%100\% of the testdata, 1n5×1041 \le n \le 5 \times 10^4, 1m1051 \le m \le 10^5.

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