8511: link with Running

内存限制:128 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:1 通过:1

题目描述

link hates running.

Today, link is asked to run. Roads in BIT can be described as n nodes and mm directed edges. link has to run from node 11 to node n. When link is at node ui, he can run through the ith edge to get to node vi. Every time he runs through the ith edge, he spends ei points of energy and gains pi points of physical fitness.

As a lazy boy, link wants to spend as little energy as possible. He is also greedy and wants to gain maximum physical fitness when spending minimum energy.

Tell link the minimum energy mine he needs to spend and the maximum physical fitness maxhe can gain when spending the minimum energy.

输入格式

Each test contains multiple test cases. The first line contains the number of test cases T(1T12). Description of the test cases follows.

The first line contains two integers n,m(2n105,1m3×105), which are the number of nodes and the number of edges.

Each of the next mm lines contains four integers ui,vi,ei,pi(1ui,vin,0ei,pi109), describing an edge.

输出格式

For each test case, output min_emine and max_pmaxp in a single line, separated by one space.

It is guaranteed that THE ANSWER EXISTS and CAN BE REPRESENTED AS A NUMBER.

输入样例 复制

2
3 3
1 2 1 1
2 3 1 1
1 3 2 0
3 3
1 2 1 1
2 3 1 1
1 3 1 0

输出样例 复制

2 2
1 0