The Pythagorean expectation has the same shape as the Pythagorean theorem and is used often in baseball and other sports. Bill James defined it, and it measures how well a team did over a season. For a baseball team the Pythagorean expectation W is
W=S2+A2S2
where S is the total number of runs the team scored and A is the total number of runs it allowed.
Comparing this value with the real win rate tells you how the season went. Suppose a team scored 619 runs and allowed 889 runs in one season. Then S=619 and A=889, so W=6192/(6192+8892)=0.326. If every team plays 128 games in a season, that team was expected to win 0.326×128=41.728 games. Winning 49 games means the season went better than expected. A team with S=715 and A=719 has W=0.497 and was expected to win 0.497×128=63.616 games, so winning 58 falls short.
You are given the match records of n teams. Compute the Pythagorean expectation of every team from those records, then print the largest and the smallest of them.
Read from standard input. The first line holds the number of test data sets T. The first line of each test data set holds the number of teams n (2≤n≤1000) and the total number of matches m (2≤m≤1000). Each of the next m lines describes one match as four integers a, b, p, q: team a played team b, team a scored p runs and team b scored q runs. Here 1≤a=b≤n, and p and q are integers between 0 and 20. Teams inside one test data set do not have to play the same number of matches. If a team's total scored runs and total allowed runs are both 0, its expectation is defined as 0.
Write to standard output. For each test data set print two integers, one per line. The first line holds the integer part of the maximum Pythagorean expectation multiplied by 1,000, and the second line holds the integer part of the minimum Pythagorean expectation multiplied by 1,000.