#Q79. 「一本通 3.2 练习 3」最短路计数

「一本通 3.2 练习 3」最短路计数

Description

Given an undirected and unweighted graph with NN vertices and MM edges, where the vertices are labeled from 11 to NN. Determine the number of shortest paths from vertex 11 to each of the other vertices.

Input Format

The first line contains two positive integers NN and MM, representing the number of vertices and edges in the graph, respectively.

The next MM lines each contain two positive integers xx and yy, indicating an edge between vertex xx and vertex yy. Note that there may be self-loops and multiple edges.

Output Format

Output NN lines, each containing a non-negative integer. The ii-th line should output the number of different shortest paths from vertex 11 to vertex ii, modulo 100003100003. If vertex ii is unreachable from vertex 11, output 00.

Sample 1

There are 44 shortest paths from 11 to 55: 22 paths via 12451 \rightarrow 2 \rightarrow 4 \rightarrow 5 and 22 paths via 13451 \rightarrow 3 \rightarrow 4 \rightarrow 5 (since there are 22 edges between 44 and 55).

5 7
1 2
1 3
2 4
3 4
2 3
4 5
4 5

1
1
1
2
4

Data Range and Hints

For 20%20\% of the data, N100N \le 100;

For 60%60\% of the data, N1000N \le 1000;

For 100%100\% of the data, 1N100000,0M2000001 \le N \le 100000, 0 \le M \le 200000.