Time limit
2s
Memory limit
128 MB
A country has N cities numbered 0, 1, 2, ..., N-1. You are currently in city S and want to drive to city T.
Some pairs of cities are connected by roads. Each road has a length and a fatigue value for driving along that road in a particular direction. The same road may have different fatigue values in its two directions. A fatigue value may be negative, meaning that driving in that direction is satisfying instead of tiring.
When leaving a city, you may use only directed roads whose fatigue is the minimum among all directed roads leaving that city. If several directed roads from a city share that minimum fatigue, all of them may be used.
Among all routes from S to T that use only allowed roads, choose one with the minimum total fatigue. If several routes have that same total fatigue, choose one with the minimum total length.
Given the road information, compute the total fatigue and total length of an optimal route.
The first line contains four integers N, M, S, and T. N is the number of cities and satisfies 1 <= N <= 100. M is the number of roads and satisfies 0 <= M <= 5000.
Each of the next M lines contains five integers u, v, a, c, and b. This means there is a road of length c connecting city u and city v; driving from u to v has fatigue a, and driving from v to u has fatigue b.
The length c is an integer from 1 to 100. Each fatigue value a and b is an integer from -100 to 100. There may be multiple roads connecting the same two cities.
If an optimal route exists, print its total fatigue and total length separated by a space.
If there is no route from S to T, print VOID. If the total fatigue can be made arbitrarily small, print UNBOUND.