1231: 最短距离

Memory Limit:32 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:13 Solved:7

Description

N个城市,标号从0到N-1,M条道路,第K条道路(K从0开始)的长度为2^K,求编号为0的城市到其他城市的最短距离。

Input

第一行两个正整数N(2<=N<=100)M(M<=500),表示有N个城市,M条道路,
接下来M行两个整数,表示相连的两个城市的编号。

Output

N-1行,表示0号城市到其他城市的最短路,如果无法到达,输出-1,数值太大的以MOD 100000 的结果输出。

Sample Input Copy

4 3
0 1
1 2
2 0

Sample Output Copy

1
3
-1