#include <iostream>
using namespace std; 
int main(int argc, char** argv) {
	int n,a[1005],b[1005];
	cin>>n;
	int mmin1=1e5+1,mmin2=1e5+1;
	int _mmin1,_mmin2;
	for(int i=1;i<=n;i++)
	{   cin>>a[i]>>b[i];
	    if(a[i]<mmin1)
	    {   mmin1=a[i];_mmin1=i;
		}
		if(b[i]<mmin2)
		{   mmin2=b[i];_mmin2=i;
		}
	}
	if(_mmin1==_mmin2)
	{   int x=mmin1+mmin2;
	    int ___mmin2=1e5+1;
	    for(int i=1;i<=n;i++)
	    {   if(b[i]<___mmin2&&i!=_mmin2)
	       {   ___mmin2=b[i];
		   }
		}
	    int y=max(mmin1,___mmin2);
	    int ___mmin1=1e5+1;
	    for(int i=1;i<=n;i++)
	    {   if(a[i]<___mmin1&&i!=_mmin1)
	       {   ___mmin1=a[i];
		   }
		}
		int z=max(___mmin1,mmin2);
		cout<<min(min(x,y),z);
	}
	else
	cout<<max(mmin1,mmin2);
	return 0;
}
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define int ll
#define each(i, a) for (auto &&i : (a))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using vvs = vector<vs>;
using vd = vector<ld>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using P = pair<int, int>;
using vp = vector<P>;
using int128 = __int128_t;//cin coutはできない
template <class T>
using greater_queue = priority_queue<T, vector<T>, greater<T>>;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a / gcd(a, b) * b;};
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

template <class T>
void CVEC(const T &v) {
	int c = v.size() - 1;
	for (int i = 0; i < c; i++) cout << v[i] << ' ';
	if (c > -1) cout << v[c];
	cout << '\n';
}

#pragma endregion header

int XMAX = 10000;
int YMAX = 10000;


struct Rectangle{
	int a, b, c, d;
};

struct Point{
	int id, x, y, r;
};

void COUT(Rectangle	x){
	cout << x.a << " " << x.b << " " << x.c << " " << x.d << endl;
}

set<P> occupied;

signed main(){
    int n; cin >> n;
	vector<Point> Ps;
	map<int, Rectangle> ans;
	rep(i,n){
		int x, y, r; cin >> x >> y >> r;
		Ps.push_back({i, x, y, r});
	}
	sort(ALL(Ps), [](Point a, Point b){return a.r > b.r;});
	/*
	rep(i,n){
		int a = Ps[i].x;//x
		int b = Ps[i].y;//y
		int r = Ps[i].r;
		cout << a << " " << b << " " << r << endl;
	}
	*/
	int x = Ps[0].x;//x
	int y = Ps[0].y;//y
	int id = Ps[0].id;
	int r = Ps[0].r;
	int hen = (int)sqrt(r);
	//cout << hen << endl;
	ans[id] = {x, y, min(x + hen, XMAX), min(YMAX, y + hen)};
	rep(i,n){
		if(i == id) continue;
		ans[i] = {i, 0, i+1, 1};
	}
	rep(i,n){
		COUT(ans[i]);
	}
}