Report Card

Given N (x, y) points, find positive integers a and b up to 100 that minimize the sum of squared residuals of f(x) = ax + b.

Easy3Brute forceMathImplementationInterviewNo attempts yetTime limit1sMemory limit256 MB

Problem

Dongha failed another course this semester and landed on academic probation again. To stay off the list next time, he decided to study.

Dongha wondered how much study time turns into how many points, so he surveyed NN students. Student ii studied for xix_i hours and scored yiy_i points.

From this data he wants to estimate the exam score after xx hours of study as f(x)=ax+bf(x) = ax + b. Find aa and bb for him.

A function f(x)f(x) that predicts an exam score from study time should keep the gap between f(xi)f(x_i) and yiy_i small on every record (xi,yi)(x_i, y_i).

RSS (residual sum of squares) turns that idea into a formula. The smaller the RSS, the better the model fits the data.

RSS=i=1N(yif(xi))2\text{RSS} = \sum_{i=1}^{N}\left(y_i - f(x_i)\right)^2

Among the positive integers aa and bb that are at most 100, find the pair that minimizes RSS. The intermediate values grow large, so watch out for overflow.

Input

The first line contains the number of records NN. (2N1002 \le N \le 100)

Each of lines 2 through N+1N+1 contains the study time xix_i and the exam score yiy_i of student ii, in that order. (1xi,yi10001 \le x_i, y_i \le 1000, and xix_i and yiy_i are integers)

Output

Print aa and bb that minimize RSS on one line, separated by a space.

No input has more than one pair (a,b)(a, b) reaching the minimum RSS.