#1134
Unrated
UTRKA
시간 제한
2s
메모리 제한
32MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Author: Goran Žužić

Mirko and Slavko are the only two contestants at the Grand Prix of Dabrovina Donja which is driven through nearby villages. The villages are connected via one-way roads, and for each road i we know Mi and Si, the time necessary for Mirko and Slavko to cross that road. The race itself is circular (meaning it starts and begins in the same village), but the route itself hasn't been determined yet.

Mirko has bribed the organisers of the race so they'd pick a route in his favour. Specifically, the organisers are going to pick the shortest route (containing the minimal number of roads) such that Mirko is strictly faster than Slavko on that route. If, by any chance, there are several such routes, the organisers choose the one where Mirko gains maximal advantage.

입력

The first line of input contains two integers N, M (2 ≤ N ≤ 300, 2 ≤ M ≤ N(N-1)), the number of villages and the number of connecting roads. Each of the following M lines contains 4 integers Ai, Bi, Mi, Si (1 ≤ Ai, Bi ≤ N, Ai ≠ Bi, 0 ≤ Si, Mi ≤ 106). Respectively, the initial and ending village of the ith road, the time necessary for Mirko and the time necessary for Slavko to cross that road. There won't exist two different roads that connect the same pair of villages in the same direction.

출력

The first and only line of output must contain two integers: the shortest possible route (with the minimal number of roads) such that Mirko wins, and the maximal advantage Mirko can gain on a route of the shortest length.

Please note: The input data will be such that a route which meets the conditions from the text will always exist.

예제 입력 1

3 4
1 2 3 0
2 3 3 0
3 1 0 100
2 1 0 4

예제 출력 1

2 1

예제 입력 2

5 7
1 2 4 1
2 3 5 1
3 1 1 6
1 3 15 5
2 4 7 5
4 5 1 4
5 3 1 0

예제 출력 2

5 2
코드 제출

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

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