#include<bits/stdc++.h>

using namespace::std;

long mat[10000][10000];

class Advertisement{
    public:
        void set_val(int x,int y,int inr);
        long get_height();
        long get_width();
        long obtain_patch(long mode);
        long a;
        long b;
        long c;
        long d;
        long s;
        long r;
        long mode1;
        long mode2;
        long mode3;
        long mode4;
};

void Advertisement::set_val(int x,int y,int inr){
    a = x;
    b = y;
    c = x+1;
    d = y+1;
    r = inr;
    mode1 = 1;
    mode2 = 1;
    mode3 = 1;
    mode4 = 1;
    mat[a][b] = 1;
    s = 1;
}

long Advertisement::obtain_patch(long mode){ //mode:1->left 2->right 3->upper 4->lower
    if(mode == 1){
        if(a-1<0 || mode1 != 1){
            return -1;
        }else{
            for(int i=b;i<d;i++){
                if(mat[a-1][i] != 0){
                    mode1 = -1;
                    return -1;
                }
            }
            for(int i=b;i<d;i++){
                mat[a-1][i] = 1;
            }
            s += get_height();
            a-=1;
        }
    }else if(mode == 2){
        if(c>9999 || mode2 != 1){
            return -1;
        }else{
            for(int i=b;i<d;i++){
                if(mat[c][i] != 0){
                    mode2 = -1;
                    return -1;
                }
            }
            for(int i=b;i<d;i++){
                mat[c][i] = 1;
            }
            s += get_height();
            c+=1;
        }
    }else if(mode == 3){
        if(b-1<0 || mode3 != 1){
            return -1;
        }else{
            for(int i=a;i<c;i++){
                if(mat[i][b-1] != 0){
                    mode3 = -1;
                    return -1;
                }
            }
            for(int i=a;i<c;i++){
                mat[i][b-1] = 1;
            }
            s += get_width();
            b-=1;
        }
    }else{
        if(d>9999 || mode4 != 1){
            return -1;
        }else{
            for(int i=a;i<c;i++){
                if(mat[i][d] != 0){
                    mode4 = -1;
                    return -1;
                }
            }
            for(int i=a;i<c;i++){
                mat[i][d] = 1;
            }
            s += get_width();
            d+=1;
        }
    }
    return 0;
}

long Advertisement::get_width(){
    return d-b;
}

long Advertisement::get_height(){
    return c-a;
}

int main(){
    long n;
    cin >> n;
    long x,y,r;
    Advertisement *ad = new Advertisement[n];
    for(int i=0;i<n;i++){
        cin >> x >> y >> r;
        ad[i].set_val(x,y,r);
    }
    clock_t start,time;
    start = clock();
    bool notstop = true;
    while(notstop){
        for(int i=0;i<n && notstop;i++){
            for(int j=1;j<5 && notstop;j++){
                time = clock();
                if((double)(time-start)/CLOCKS_PER_SEC > 4.8){
                    notstop = false;
                }
                ad[i].obtain_patch(j);
            }
        }
    }

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

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define mp make_pair
#define fr first
#define sc second

int n;
int x[202],y[202],r[202];

struct A{
	int a[202],b[202],c[202],d[202];
	void out(){
		for(int i=0;i<n;i++){
			printf("%d %d %d %d\n",a[i],b[i],c[i],d[i]);
		}
	}
};

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d%d%d",&x[i],&y[i],&r[i]);
	
	A ans;
	for(int i=0;i<n;i++){
		ans.a[i]=x[i]; ans.c[i]=x[i]+1;
		ans.b[i]=y[i]; ans.d[i]=y[i]+1;
	}
	ans.out();
}
