Problem:
Score: 300 points

Problem Statement

In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc.

The pyramid had center coordinates (C_X, C_Y) and height H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0).

Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information:

C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1.

Additionally, he obtained N pieces of information. The i-th of them is: "the altitude of point (x_i, y_i) is h_i."

This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.

Constraints

N is an integer between 1 and 100 (inclusive).

x_i and y_i are integers between 0 and 100 (inclusive).

h_i is an integer between 0 and 10^9 (inclusive).

The N coordinates (x_1, y_1), (x_2, y_2), (x_3, y_3), ..., (x_N, y_N) are all different.

The center coordinates and the height of the pyramid can be uniquely identified.

Input

Input is given from Standard Input in the following format:

N
x_1 y_1 h_1
x_2 y_2 h_2
x_3 y_3 h_3
:
x_N y_N h_N

Output

Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between.

Sample Input 1

4
2 3 5
2 1 5
1 2 5
3 2 5

Sample Output 1

2 2 6

In this case, the center coordinates and the height can be identified as (2, 2) and 6.

Sample Input 2

2
0 0 100
1 1 98

Sample Output 2

0 0 100

In this case, the center coordinates and the height can be identified as (0, 0) and 100.

Note that C_X and C_Y are known to be integers between 0 and 100.

Sample Input 3

3
99 1 191
100 1 192
99 0 192

Sample Output 3

100 0 193

In this case, the center coordinates and the height can be identified as (100, 0) and 193.

Solution in C (GCC 9.2.1) (judge verdict: Wrong Answer)

#include <stdio.h>

#define size 128
#define ZNA 1
#define ZNB 2
#define ZNC 4
#define ZND 8

int readint();
inline int readint()
{
    register int t = 0;
    register char c;
    //int minus = 0;
    while((c = getchar()) < '-');
    //if (c == '-') minus = 1, c = getchar();
    c -= '0';
    do
    {
        t = t * 10 + c;
    }while((c = getchar() - '0') >= 0);
    //return minus ? (-t) : t;
    return t;
}

struct point
{
    int x;
    int y;
    int z;
    int f;
};


int main()
{
    int n, x1 = 0, x2 = 100, y1 = 0, y2 = 100, dx, dy, dz;
    struct point point[size];
    n = readint();
    for (int i = 0; i < n; i++)
    {
        point[i].x = readint();
        point[i].y = readint();
        point[i].z = readint();
        point[i].f = 0;
    }
    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
    {
        #define pout(i, x) (point[i].x <= x##1 || point[i].x >= x##2)
        if (pout(i, x) && pout(i, y) && pout(j, x) && pout(j, y))
            continue;
        dx = point[i].x - point[j].x;
        dy = point[i].y - point[j].y;
        dz = point[i].z - point[j].z;
        if (dx > 0)
        {
            if (dy > 0)
            {
                #define test(dx, dy, A, B, C, D) \
                if ((dx) + (dy) == dz) \
                { \
                    point[i].f = point[j].f = ZN##A|ZN##B|ZN##D; \
                } \
                else if ((dx) + (dy) == -dz) \
                { \
                    point[i].f = point[j].f = ZN##B|ZN##C|ZN##D; \
                } \
                else if ((dx) - (dy) == dz) \
                { \
                    point[i].f = point[j].f = ZN##A|ZN##C|ZN##D; \
                } \
                else if ((dx) - (dy) == -dz) \
                { \
                    point[i].f = point[j].f = ZN##A|ZN##B|ZN##C; \
                } \
                else if ((dx) > (dy)) \
                { \
                    point[i].f |= ZN##B|ZN##C; \
                    point[j].f |= ZN##A|ZN##D; \
                } \
                else if ((dx) < (dy)) \
                { \
                    point[i].f |= ZN##C|ZN##D; \
                    point[j].f |= ZN##A|ZN##B; \
                } \
                else \
                { \
                    point[i].f = ZN##B|ZN##C|ZN##D; \
                    point[j].f = ZN##A|ZN##B|ZN##D; \
                }
                test(dx, dy, A, B, C, D);
            }
            else
            {
                test(dx, -dy, D, C, B, A);
            }
        }
        else if (dx < 0)
        {
            if (dy > 0)
            {
                test(-dx, dy, B, A, D, C);
            }
            else if (dy < 0)
            {
                test(-dx, -dy, C, D, A, B);
            }
        }
        #define update(i) \
        _update(i, ZNB|ZNC|ZND, x2, y2, min, min) \
        _update(i, ZNA|ZNC|ZND, x1, y2, max, min) \
        _update(i, ZNA|ZNB|ZND, x1, y1, max, max) \
        _update(i, ZNA|ZNB|ZNC, x2, y1, min, max)
        #define _update(i, z, _x, _y, xm, ym) \
        if (point[i].f == (z)) \
            _x = xm(_x, point[i].x), _y = ym(_y, point[i].y);
        #define max(a, b) (a > b ? a : b)
        #define min(a, b) (a < b ? a : b)
        #define calc_h(i) (point[i].z + abssub(point[i].x, x) + abssub(point[i].y, y))
        #define abssub(a, b) ((a > b) ? (a - b) : (b - a))
        update(i)
        update(j)
    }
    for (int x = x1; x <= x2; x++)
        for (int y = y1; y <= y2; y++)
    {
        int h = calc_h(0);
        for (int i = 0; i < n; i++)
        {
            if (h != calc_h(i))
                goto next;
        }
        printf("%d %d %d", x, y, h);
        goto end;
        next:
        continue;
    }
    end:
    return 0;
}

#define ZNA 1
#define ZNB 2
#define ZNC 4
#define ZND 8