If anyone wants some arbitrary bronze problems (especially if you’re still starting out), I’ll let this be a thread to post them. If you want to propose your own problems, you can make this a marathon as well, but for now I have at least two problems I will post here. In any case, please post original problems instead of already existing USACO problems.

Here’s the first (below). If you solve it, feel free to post your solution! Include hide tags so others can try

Once someone successfully solves this, I will post the second problem.

Grazing Patterns

Farmer John is constructing a new grass field. Each of his N cows, conveniently numbered 1 \dots N, has a favorite grazing pattern, and the accommodating farmer he is, Farmer John wants to ensure the new field remains large enough for all cows to graze without having to exit the field.

Formally, if the grass field is a perfect axis-aligned rectangle (horizontal sides parallel to the x axis and vertical sides parallel to the y axis), the favorite grazing pattern of cow i starts at some point (x_i, y_i), travels horizontally h_i units (rightward for positive h_i, leftward for negative h_i, and nowhere for h_i=0) to the point (x_i + h_i, y_i), and finally travels vertically v_i units (upward for positive v_i, downward for negative v_i, and nowhere for v_i=0) to the point (x_i + h_i, y_i + v_i).

For instance, the grazing pattern of a cow starting at (3,4) traveling horizontally -4 and vertically 2 would take her left from (3,4) to (-1,4) and up from (-1,4) to (-1,6).

It is possible for the grazing patterns of two cows to cross – assume that they travel around each other without deviating significantly from their paths. The new field does not have to be in the first quadrant – it can be anywhere in the coordinate plane as long as it remains axis-aligned and satisfies the constraints.

Given the grazing patterns of all N cows, find the minimum horizontal and vertical dimensions allowable for Farmer John’s new field.

INPUT FORMAT (graze.in):

The first line of input contains the value of N. It is guaranteed that 1 \leq N \leq 10^5.

The next N lines of input are as follows:

For all cows i = 1 \dots N, line i+1 contains the space-separated integers x_i, y_i, h_i, v_i describing the favorite grazing pattern of cow i. It is guaranteed that -10^5 \leq x_i, y_i, h_i, v_i \leq 10^5.

OUTPUT FORMAT (graze.out):

Output one line containing two space-separated integers describing the answer, first the minimum horizontal dimension and second the minimum vertical dimension.

SAMPLE INPUT:

2

3 4 -4 2

0 0 4 4

SAMPLE OUTPUT:

5 6

The field can have bottom left corner (-1,0) and top right corner (4,6).