#include <bits/stdc++.h>
#include <chrono>
#include <ctime>
using namespace std;
using namespace std::chrono;
using i64 = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
constexpr int INF = 1001001001;

constexpr bool is_multiple = false;

struct Rect {
    int x1, y1, x2, y2;

    Rect() {}
    Rect(int a, int b, int c, int d) { x1 = a; y1 = b; x2 = c; y2 = d; }

    int get_area() {
        return (x2 - x1) * (y2 - y1);
    }

    bool is_valid() {
        return x1 < x2 && y1 < y2;
    }
};

Rect merge(Rect a, Rect b) {
    return (Rect){max(a.x1, b.x1), max(a.y1, b.y1), min(a.x2, b.x2), min(a.y2, b.y2)};
}

// 共通部分が存在しない判定
// 計算量: O(n)
bool is_ok(vector<Rect>& v, int i) {
    int n = v.size();
    
    bool flag = true;

    rep(j, n) {
        if (i == j) continue;

        auto mg = merge(v[i], v[j]);

        if (mg.is_valid()) flag = false;
    }

    return flag;
}

// スコア計算
// 計算量: O(n)
i64 calc_score(vector<Rect>& v, vec& r) {
    int n = r.size();
    double res = 0;

    rep(i, n) {
        int s = v[i].get_area();
        double t = (double)(min(r[i], s)) / max(r[i], s);
        res += 1 - (1 - t) * (1 - t);
    }

    res *= 1000000000;
    res /= n;

    i64 ret = round(res);

    return ret;
}

static uint32_t randXor()
{
    static uint32_t x = 123456789;
    static uint32_t y = 362436069;
    static uint32_t z = 521288629;
    static uint32_t w = 88675123;
    uint32_t t;
 
    t = x ^ (x << 11);
    x = y; y = z; z = w;
    return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
}

static double next_double() {
    return (randXor() + 0.5) * (1.0 / UINT_MAX);
}

constexpr int expand_diff = 1;

bool modify(vector<Rect>& rects, vec& r, double prog) {
    int n = rects.size();
    int i = randXor() % n;

    // if (rects[i].get_area() >= r[i]) return;

    int side = randXor() % 4;

    if (side == 0 && rects[i].x1-expand_diff >= 0) rects[i].x1 -= expand_diff;
    else if (side == 1 && rects[i].y1-expand_diff >= 0) rects[i].y1 -= expand_diff;
    else if (side == 2 && rects[i].x2+expand_diff <= 10000) rects[i].x2 += expand_diff;
    else if (side == 3 && rects[i].y2+expand_diff <= 10000) rects[i].y2 += expand_diff;

    return is_ok(rects, i);
}

void solve() {
    int n;
    cin >> n;
    vec x(n), y(n), r(n);
    rep(i, n) cin >> x[i] >> y[i] >> r[i];

    vector<Rect> rects(n);
    // 初期化
    rep(i, n) {
        rects[i] = (Rect){x[i], y[i], x[i]+1, y[i]+1};
    }

    // 焼きなまし
    auto startClock = system_clock::now();

    const double start_temp = 1250;
    const double end_temp = 50;
    const double end_time = 4.8;

    double time = 0.0;

    do {
        const double progress_ratio = time / end_time;

        auto new_rects = rects;
        bool flag = modify(new_rects, r, progress_ratio);
        if (!flag) continue;

        auto new_score = calc_score(new_rects, r);
        auto pre_score = calc_score(rects, r);
        auto delta_score = new_score - pre_score;

        double temp = start_temp + (end_temp - start_temp) * progress_ratio;

        double prob = exp(delta_score / temp);

        if (prob > next_double()) {
            rects = new_rects;
        }

        time = (duration_cast<microseconds>(system_clock::now() - startClock).count() * 1e-6);
    }
    while (time < end_time);

    // printf("\n");

    rep(i, n) printf("%d %d %d %d\n", rects[i].x1, rects[i].y1, rects[i].x2, rects[i].y2);

    // auto l_sc = calc_score(rects, r);
    // cout << fixed << setprecision(15) << l_sc * 1e-9 << endl;
}

int main() {
    int t = 1;
    if (is_multiple) cin >> t;
    while (t--) solve();
    return 0;
}

#include <bits/stdc++.h>   
#define CIT_MARK ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ll long long 
#define pll pair<ll,ll>
#define pb push_back
#define M 1000000007
#define lc '\n'
using namespace std;
int main()
{
    CIT_MARK
    ll n;
    cin>>n;
    ll a[n][5];
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<5;j++)
        {
            cin>>a[i][j];
        }
    }
    auto check=[&](ll mid){
        set<ll> st;
        for(ll i=0;i<n;i++)
        {
            ll val=0;
            for(ll j=0;j<5;j++)
            {
                if(a[i][j]>=mid)
                {
                    val+=pow(2LL,j);
                }
            }
            st.insert(val);
        }
        for(auto i:st)
        {
            for(auto j:st)
            {
                for(auto k:st)
                {
                    if((i | j | k)== 31)
                    {
                        return true;
                    }
                }
            }
        }
        return false;
    };
    ll l=0,r=1e9;
    ll ans=0;
    while(l<=r)
    {
        ll mid=(l+r)/2;
        bool is=check(mid);
        if(is)
        {
            ans=mid;
            l=mid+1;
        }
        else
        {
            r=mid-1;
        }
    }
    cout<<ans<<lc;
    return 0;
}
