#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
#define P pair<int,int>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
#define T tuple<int, int, int>
#define PP pair<P,P>
#define ALL(a) a.begin(), a.end()

int main(){
    int n;
    cin >> n;
    vector<PP> inputData;
    rep(i,n){
        int x, y, r;
        cin >> x >> y >> r;
        PP p = PP(P(r,i),P(x,y));
        inputData.push_back(p);
    }
    sort(ALL(inputData));
    // for (auto p : inputData){
    //     printf("%d %d %d %d\n", p.first.first, p.first.second, p.second.first, p.second.second);
    // }

    vector<PP> outputData(n);
    //広告は最低でも1の面積を持つので面積1で初期化
    rep(i,n){
        int index, x, y;
        index = inputData[i].first.second;
        x = inputData[i].second.first;
        y = inputData[i].second.second;
        outputData[index] = PP(P(x,y),P(x+1, y+1));
    }
    rep(i,n){
        int r, index, x, y;
        r = inputData[i].first.first;
        index = inputData[i].first.second;
        x = inputData[i].second.first;
        y = inputData[i].second.second;
        vector<P> divisors;
        //rについて約数列挙
        for (int i=1; i*i<=r; i++){
            if (r % i == 0){
                divisors.push_back(P(i,r/i));
            }
        }
        //交差検出
        int m = divisors.size();
        bool missFlag = true;
        rep(j,m){
            bool jadge = true;
            int vertical = divisors[j].first;
            int heng = divisors[j].second;
            //広告がはみ出すならbreak;
            if (x + vertical > 1e4) continue;
            if (y + heng > 1e4) continue;
            rep(k,(int)outputData.size()){
                if (k == index) continue;
                int a1 = outputData[k].first.first;
                int a2 = outputData[k].first.second;
                int b1 = outputData[k].second.first;
                int b2 = outputData[k].second.second;
                if (a1<=x && x<=b1 && a2<=y && y<=b2) jadge = false;
                if (a1<=x+vertical && x+vertical<=b1 && a2<=y+heng && y<=b2+heng) jadge = false;
                // if (x<=a1 && a1<=x+vertical && y<=a2 && a2<=y+heng) jadge = false;
                // if (x<=b1 && b1<=x+vertical && y<=b2 && b2<=y+heng) jadge = false;
                if (x<a1 && x+vertical>b1 && y>a2 && y+heng<b2) jadge = false;
                if (x<=b1 && b1<=x+vertical && y<=a2 && a2<=y+heng) jadge = false;
                if (x<=a1 && a1<=x+vertical && y<=b2 && b2<=y+heng) jadge = false;

            }
            //入れることができるなら広告を入れる．
            if (jadge){
                missFlag = false;
                outputData[index] = PP(P(x,y),P(x+vertical,y+heng));
                break;
            }
        }
        if (missFlag){
            r /= 2;
            if (r <= 1e2){
                continue;
            }
            PP p = PP(P(r,index),P(x,y));
            inputData.push_back(p);
            n++;
        }
    }
    for (auto p : outputData){
        printf("%d %d %d %d\n", p.first.first, p.first.second, p.second.first, p.second.second);
    }
}
#include <bits/stdc++.h>

using namespace std;

#define PI 3.14159265358979323846264338327950L

const int Limit = 10000;
tuple<long long,long long,long long> T;


int main(void) {
	int n;
	cin >> n;

    vector<long long> x(n), y(n), r(n);
	vector<long long> a(n), b(n), c(n), d(n);

	vector<int>X(Limit + 5, -1);
	vector<int>Y(Limit + 5, -1);


	for (int i = 0; i < n; i++) {
        cin>>x[i]>>y[i]>>r[i];
	}

	for (int i = 0; i < n; i++) {
		a[i] = x[i];
		b[i] = y[i];
		c[i] = x[i]+1;
		d[i] = y[i]+1;
	}
	for (int i = 0; i < n; i++) {
		for (int j = a[i]; j <= b[i]; j++) {
			X[j] = i;
		}
		for (int j = c[i]; j <= d[i]; j++) {
			Y[j] = i;
		}
	}


	for (long long loop = 0; loop < 50000; loop++) {
		for (int i = 0; i < n; i++) {
            double tmp = (b[i] - a[i])*(d[i]-c[i]);
            // if(tmp > r[i]){
            //     continue;
            // }
            //     //割当が大きすぎるので縮小させる

            //     if(loop%2 ==0){
            //         //X軸方向だけを縮小
            //         if (0 <= a[i] + 1 && a[i] + 1 <= Limit && X[a[i] + 1]==i &&a[i]+1 < x[i]) {
            //             X[a[i]] = -1;
            //             a[i] = a[i] + 1;
                        
            //         }
            //         if (0 <= c[i] - 1 && c[i] - 1 <= Limit && X[c[i] - 1]==i && c[i] - 1 > x[i]) {
            //             X[c[i]] = -1;
            //             c[i] = c[i] - 1;
            //         }
            //     }else{
            //         //Y軸方向だけを縮小
            //         if (0 <= b[i] + 1 && b[i] + 1 <= Limit && Y[b[i] + 1]==i && b[i] + 1 < y[i]) {
            //             Y[b[i]] = -1;
            //             b[i] = b[i] + 1;
            //         }
            //         if (0 <= d[i] - 1 && d[i] - 1 <= Limit && Y[d[i] - 1]==i && d[i] - 1 > y[i]) {
            //             Y[d[i] ] = -1;
            //             d[i] = d[i] - 1;
            //         }
            //     }
                
            // }else{

                //割当を大きくする
                if (0 <= a[i] - 1 && a[i] - 1 <= Limit && X[a[i] - 1] == -1) {
                    a[i] = a[i] - 1;
                    X[a[i]] = i;
                }
                if (0 <= c[i] + 1 && c[i] + 1 <= Limit && X[c[i] + 1]== -1) {
                    c[i] = c[i] + 1;
                    X[c[i]] = i;
                }

                if (0 <= b[i] - 1 && b[i] - 1 <= Limit && Y[b[i] - 1]== -1) {
                    b[i] = b[i] - 1;
                    Y[b[i]] = i;
                }
                if (0 <= d[i] + 1 && d[i] + 1 <= Limit && Y[d[i] + 1]== -1) {
                    d[i] = d[i] + 1;
                    Y[d[i] ] = i;
                }
		}
	}




	for (int i = 0; i < n; i++) {
		cout << a[i] << " " << b[i] << " " << c[i] << " " << d[i] << endl;
	}






	return 0;
}

