#422
Unrated
Moorio Kart
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Bessie and Farmer John enjoy goat kart racing. The idea is very similar to Go-Kart racing that others enjoy, except the karts are pulled by goats and the track is made from nearby farmland. The farmland consists of NN meadows and MM roads, each connecting a pair of meadows.

Bessie wants to make a course from nearby farms. A farm is a subset of two or more meadows within which every meadow can reach every other meadow along a unique sequence of roads.

The nearby farmland may contain multiple farms. Suppose there are KK farms. Bessie would like to make a goat kart loop by connecting all KK farms by adding KK roads of length XX. Each farm should be visited exactly once and at least one road must be traversed inside each farm.

To make the course interesting for racers, the total length of the track should be at least YY. Bessie wants to know the sum, over all such interesting tracks, of the total track lengths. A track is different from another if there are two meadows which are adjacent (after adding the roads between farms) in one track but not the other. Please note that only the roads chosen matter, and not the direction the goat karts will travel along those roads.

입력

The first line of input contains NN, MM, XX, and YY where 1N15001 \leq N \leq 1500, 1MN11 \leq M \leq N-1, and 0X,Y25000 \leq X, Y \leq 2500.

Each of the MM following lines describe roads. The lines are of the form: AiA_i BiB_i DiD_i, meaning that meadows AiA_i and BiB_i are connected with a road of integer length DiD_i (1Ai,BiN1 \leq A_i, B_i \leq N, 0Di25000 \leq D_i \leq 2500). Each meadow is incident to at least one road, and there are no cycles of roads.

In at least 70% of the test cases, it is also guaranteed that N1000N \leq 1000 and Y1000Y \leq 1000.

출력

Output a single integer, giving the sum of track lengths over all interesting tracks. As the sum of track lengths can be quite large, print the sum of lengths modulo 109+710^9+7.

예제 입력 1

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

예제 출력 1

54
코드 제출

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

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