Source : NOI2017贵州省选
Description

Input
Output
Sample Input
6 6 1 4
1 2 3
2 3 2
2 4 4
3 6 4
1 5 5
5 6 3
0 3 3 4 6
1 3 4 5 6
0 1 3
1 4 3 4 5 6
Sample Output
10
6
Hint