All problems

Comparing Two Candidate Lines

mediumPythonLinear Regression

Two analysts at Kestrel Freight have each proposed a fuel rule, and neither will give way. Both rules are straight lines, both look reasonable on a chart, and the depot needs a decision it can defend rather than an argument. The tie-breaker they have agreed on is the total squared residual on the recorded deliveries: for each delivery take the gap between the rule's cost and the real cost, square it, and add those across every delivery. The rule with the smaller total wins. Squared, not raw sizes — a rule that is wrong by 3 once is judged worse than one that is wrong by 1.5 three times.

Task: Print which of the two rules fits the recorded deliveries better.

Input

The first line holds rule A as two numbers separated by a single space: its slope, then its intercept. The second line holds rule B in the same form. The third line holds one integer n, the number of deliveries. Then come n lines, each holding a distance and the real cost, separated by a single space.

Output

One line, exactly one of model A, model B, or tie. Print tie only when the two totals come out exactly equal; a rule wins only by being strictly lower.

Example:

Input:
2 0
1 1
3
1 2
2 4
3 6

Output:
model A

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…