#639
Unrated
A Graph Problem
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

To improve her mathematical knowledge, Bessie has been taking a graph theory course and finds herself stumped by the following problem. Please help her!

You are given a connected, undirected graph with vertices labeled 1N1\dots N and edges labeled 1M1\dots M (2N21052\le N\le 2\cdot 10^5, N1M4105N-1\le M\le 4\cdot 10^5). For each vertex vv in the graph, the following process is conducted: ​ Let S={v}S=\{v\} and h=0h=0.While S<N|S|<N, ​ Out of all edges with exactly one endpoint in SS, let ee be the edge with the minimum label.Add the endpoint of ee not in SS to SS.Set h=10h+eh=10h+e. ​ Return h(mod109+7)h\pmod{10^9+7}. ​ Determine all the return values of this process. ​

입력

The first line contains NN and MM. ​ Then follow MM lines, the eeth containing the endpoints (ae,be)(a_e,b_e) of the eeth edge (1ae<beN1\le a_e<b_e\le N). It is guaranteed that these edges form a connected graph, and at most one edge connects each pair of vertices.

출력

Output NN lines, where the iith line should contain the return value of the process starting at vertex ii.

예제 입력 1

3 2
1 2
2 3

예제 출력 1

12
12
21

예제 입력 2

5 6
1 2
3 4
2 4
2 3
2 5
1 5

예제 출력 2

1325
1325
2315
2315
5132

예제 입력 3

15 14
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15

예제 출력 3

678925929
678925929
678862929
678787329
678709839
678632097
178554320
218476543
321398766
431520989
542453212
653475435
764507558
875540761
986574081

점수

Input 4: N,M2000N,M\le 2000Inputs 5-6: N2000N\le 2000Inputs 7-10: N10000N\le 10000Inputs 11-14: ae+1=bea_e+1=b_e for all eeInputs 15-23: No additional constraints.

코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.