#include<bits/stdc++.h>
using namespace std;
    
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(x) (x).begin() , (x).end()
#define sz(x) ((int)(x).size())
template<class T>bool chmax(T &a, const T &b) { if (a<b) {a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) {a=b; return 1; } return 0;}
using ll = long long;
const long long INF =(ll)1<<60;

bool prime(ll N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}
    
int main(){
    int n;
    cin >> n;
    vector<int> x(n),y(n),r(n);
    vector<ll> R(n);
    vector<vector<int>> judge(10000,vector<int> (10000));
    map<int,int> Ydomain;

    rep(i,10000) rep(j,10000) judge[i][j] = 0;

    rep(i,n){
        cin >> x[i] >> y[i] >> r[i];
        judge[y[i]][x[i]] = 1;
    }

    rep(i,n) Ydomain[y[i]] = 1;

    vector<pair<int,int>> location(n);
    rep(i,n){
        location[i].first = x[i];
        location[i].second = y[i];
    }

    bool flag = true;

    rep(i,n){
        int now = location[i].first;
            while(flag){
                now++;
                if(now < 1 || now > 9999) break;
                if(judge[location[i].second][now] == 1) {
                    flag = false;
                }
            }
            flag = true;
        location[i].first = now;
    }

    rep(i,n){
        int now = location[i].second;
            while(flag){
                now++;
                if(now < 1 || now > 9999) break;
                if(Ydomain.count(now)) {
                    flag = false;
                }
            }
            flag = true;
        location[i].second = now;
    }

    rep(i,n) R[i] = (ll)abs(location[i].first - x[i]) * abs(location[i].second - y[i]);
    
    vector<pair<int,int>> prime1_location(n);
    rep(i,n){
        prime1_location[i].first = location[i].first;
        prime1_location[i].second = location[i].second;
    }

    vector<pair<int,int>> prime2_location(n);
    rep(i,n){
        prime2_location[i].first = location[i].first;
        prime2_location[i].second = location[i].second;
    }

    rep(i,n){
        if(!prime(r[i])){
            while(abs(location[i].first - x[i]) * abs(location[i].second - y[i]) > r[i]){
                if(location[i].first > -1 && location[i].first - x[i] > 1) location[i].first--;
                if(location[i].second > -1 && location[i].second - y[i] > 1) location[i].second--;
            }
        }else{
            while(abs(prime1_location[i].first - x[i]) * abs(prime1_location[i].second - y[i]) > r[i]){
                prime1_location[i].first = x[i] + 1;
                prime1_location[i].second--;
            }
            while(abs(prime2_location[i].first - x[i]) * abs(prime2_location[i].second - y[i]) > r[i]){
                prime2_location[i].second = y[i] + 1;
                prime2_location[i].first--;
            }
            if(abs(prime1_location[i].first - x[i]) * abs(prime1_location[i].second - y[i]) > abs(prime2_location[i].first - x[i]) * abs(prime2_location[i].second - y[i])){
                location[i].first = x[i] + 1;
                location[i].second = prime1_location[i].second;
            }else{
                location[i].second = y[i] + 1;
                location[i].first = prime2_location[i].first;
            }
        }
    }

    rep(i,n) cout<<x[i]<<" "<<y[i]<<" "<<location[i].first<<" "<<location[i].second<<endl;
}
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define BUFF ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define IO freopen("in.txt","r",stdin),freopen("out.txt","w",stdout)
#define P(x) cout<<x<<endl
#define P2(x,y) cout<<x<<' '<<y<<endl
#define P3(x,y,z) cout<<x<<' '<<y<<' '<<z<<endl
#define P4(x,y,z,u) cout<<x<<' '<<y<<' '<<z<<' '<<u<<endl
#define P5(x,y,z,u,v) cout<<x<<' '<<y<<' '<<z<<' '<<u<<' '<<v<<endl
#define P6(x,y,z,u,v,w) cout<<x<<' '<<y<<' '<<z<<' '<<u<<' '<<v<<' '<<w<<endl
#define PV(x) for(auto ii:(x)){cout<<ii<<' ';}cout<<endl
#define PN(x,n) for(int ii=1;ii<=(n);ii++){cout<<x[ii]<<' ';}cout<<endl
#define PNN(x,n,m) for(int ii=1;ii<=(n);ii++){for(int jj=1;jj<=(m);jj++){cout<<x[ii][jj]<<' ';}cout<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const ll D = 0;
const ll N = 222;
const ll mod = 1e9 + 7;
const ll inf = 1e9 + 7;
const double eps = 1e-9;

ll n;
bool visRow[10010];
vector<ll> adInRow[10010];
double score=0;
struct AD
{
	ll id,x,y,r,a,b,c,d;
	bool operator <(const AD &tmp)const
	{
		return y<tmp.y;
	}
}ad[N];
bool cmp(ll id1,ll id2)
{
	return ad[id1].y < ad[id2].y;
}
ll area(ll x,ll y,ll z,ll w)
{
	return abs(x-y) * abs(z-w);
}
int solve()
{
	cin>>n;
	ll maxX=0;
	for(ll i=1;i<=n;i++)
	{
		cin>>ad[i].x>>ad[i].y>>ad[i].r;
		ad[i].id = i;
		//visRow[ad[i].x]=true;
		adInRow[ad[i].x].push_back(i);
		maxX = max(maxX, ad[i].x);
		//P("ok");
	}
	for(ll i=0;i<10000;i++)
	{
		sort(adInRow[i].begin(),adInRow[i].end(),cmp);
	}
	ll lstX=0,lstY=0,cnt,siz;
	for(ll i=0;i<10000;i++)
	{
		if(!adInRow[i].empty())
		{
			cnt=0;
			siz = adInRow[i].size();
			lstY=0;
			for(ll j=0;j<siz;j++)
			{
				AD *now = &ad[adInRow[i][j]];
				now->a = lstY;
				now->b = now->y + 1;
				if(j == siz-1) now->b = 10000;
				lstY = now->b;

				if(i==maxX) now->d = 10000;
				else now->d = now->x + 1;

				ll tmpx = now->x;
				while(tmpx>lstX && area(now->b,now->a,now->d,tmpx)<(now->r))
				{
					tmpx--;
				}
				now->c = tmpx;//[lstx,nowx]
				
			}
			lstX = i + 1;
		}
	}
	score=0;
	for(ll i=1;i<=n;i++)
	{
		P4(ad[i].a,ad[i].c,ad[i].b,ad[i].d);
		if(D)
		{
			double s = area(ad[i].b,ad[i].a,ad[i].d,ad[i].c);
			double r = ad[i].r;
			score += 1 - pow(1 - (min(r,s)/max(r,s)), 2.);
			//P((min(r,s)/max(r,s)));
		}
	}
	if(D)
	{
		score = 1e9 * (score / n);
		cout<<"Your score: "<<(ll)score;
	}
	
	return 0; 
}

int main()
{
	//BUFF;
	if(D)IO;
	solve();
	return 0;
}