//#define _GLIBCXX_DEBUG

//#include<bits/stdc++.h>

//*
#include<vector>
#include<iostream>
#include<queue>
#include<algorithm>
#include<math.h>
#include<iomanip>
#include <numeric>
//*/
using namespace std;
#define ll long long
#define yes {cout<<"Yes"<<endl;return 0;}
#define no {cout<<"No"<<endl;return 0;}
#define YES {cout<<"YES"<<endl;return 0;}
#define NO {cout<<"NO"<<endl;return 0;}
#define cyes {cout<<"Yes"<<endl;continue;}
#define cno {cout<<"No"<<endl;continue;}

#define MOD 1000000007
#define MOD2 1000000009
#define MOD3 998244353
#define INF 2147483647
constexpr double PI = 3.14159265358979;
#define LINF 9223372036854775807

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)




#define PF push_front
#define PB push_back
#define POF pop_front
#define POB pop_back

#define MP make_pair
#define MT make_tuple

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SZ(a) (int)((a).size())

#define NEXP(a) next_permutation((a).begin(),(a).end())
#define FI first
#define SE second

#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).rbegin(), (c).rend())
#define REVERSE(c) reverse((c).begin(),(c).end())


typedef long long LL;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef vector<double> VD;
typedef vector<VD> VVD;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;






void solve(vector<pair<PII, PII>> &s,vector<pair<PII,PII>> &a)
{
    int n=s.size();
    SORT(s);
    //map<int,int>ymax;
    //ymax[0]=10000;
    rep(i,n)
    {
        int now,pre;
        now=s[i].SE.SE;
        int xmax,ymax;
        if(i==0)
        {
            a[now].FI.FI=0;
            a[now].FI.SE=0;
            a[now].SE.FI=s[i].FI.FI+1;
            a[now].SE.SE=s[i].FI.SE+1;
            //ymax[-s[i].FI.FI]=s[i].FI.SE;
            xmax=s[i].FI.FI;
            ymax=s[i].FI.SE;
        }
        else
        {
            if(s[i].FI.FI==xmax)
            {
                a[now].FI.FI=a[pre].FI.FI;
                a[now].FI.SE=a[pre].SE.SE;
                a[now].SE.FI=s[i].FI.FI+1;
                a[now].SE.SE=s[i].FI.SE+1;
                xmax=s[i].FI.FI;ymax=s[i].FI.SE;
                if(i==n-1)
                {
                      a[now].SE.SE=10000;
                }
                     if(s[n-1].FI.FI==s[i].FI.FI)
                {
                    a[now].SE.FI=10000;
                    
                }
            }
            else
            {
                
                a[now].FI.FI=a[pre].SE.FI;
                a[now].FI.SE=0;
                a[now].SE.FI=s[i].FI.FI+1;
                a[now].SE.SE=s[i].FI.SE+1;
                if(i==n-1)
                {
                      a[now].SE.SE=10000;
                }
                
                
                if(s[n-1].FI.FI==s[i].FI.FI)
                {
                    a[now].SE.FI=10000;
                    
                }
                xmax=s[i].FI.FI;
                ymax=s[i].FI.SE;
                a[pre].SE.SE=10000;
            }

        }
        pre=now;
        
    }
    
}

int main(void)
{
	int n;
	cin >> n;
    vector<pair<PII, PII>> s(n);
    vector<pair<PII,PII>> ans(n);
	rep(i, n)
	{
	    cin >> s[i].first.first>> s[i].first.second >> s[i].second.FI;
	    s[i].SE.SE=i;
	}
	
	solve(s,ans);
	
	rep(i,n)cout<<ans[i].FI.FI<<" "<<ans[i].FI.SE<<" "<<ans[i].SE.FI<<" "<<ans[i].SE.SE<<endl;
}



#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;


int n;
struct xyr {
  int x;
  int y;
  int r;
};
struct sq {
  int x1;
  int y1;
  int x2;
  int y2;
  int s;
};

vector<xyr> ad;
vector<sq> ans;
vector<bool> okArea;
clock_t start;
vector<vector<int>> area(10001, vector<int>(10001, -1));

void input () {
  cin >> n;
  ad.resize(n);
	rep(i, n) cin >> ad[i].x >> ad[i].y >> ad[i].r;
}
void init() {
  ans.resize(n);
  okArea.resize(n);
  rep(i, n) {
    ans[i].x1 = ad[i].x;
    ans[i].y1 = ad[i].y;
    ans[i].x2 = ad[i].x+1;
    ans[i].y2 = ad[i].y+1;
    ans[i].s = 1;
    area[ad[i].y][ad[i].x] = i;
    okArea[i] = false;
  }
}

void moveLeft(int i) {
  bool ok = true;
  for (int j=ans[i].y1; j<=ans[i].y2; j++) {
    if (!(ans[i].x1-1 >= 0 && area[j][ans[i].x1-1] == -1)) {
      ok = false;
      break;
    }
  }
  if (!ok) return;
  ans[i].x1--;
  for (int j=ans[i].y1; j<=ans[i].y2; j++) {
    area[j][ans[i].x1] = i;
    ans[i].s++;
  }
}
void moveRight(int i) {
  bool ok = true;
  for (int j=ans[i].y1; j<=ans[i].y2; j++) {
    if (!(ans[i].x2+1 <= 10000 && area[j][ans[i].x2+1] == -1)) {
      ok = false;
      break;
    }
  }
  if (!ok) return;
  ans[i].x2++;
  for (int j=ans[i].y1; j<=ans[i].y2; j++) {
    area[j][ans[i].x2] = i;
    ans[i].s++;
  }
}
void moveUp(int i) {
  bool ok = true;
  for (int j=ans[i].x1; j<=ans[i].x2; j++) {
    if (!(ans[i].y1-1 >= 0 && area[ans[i].y1-1][j] == -1)) {
      ok = false;
      break;
    }
  }
  if (!ok) return;
  ans[i].y1--;
  for (int j=ans[i].x1; j<=ans[i].x2; j++) {
    area[ans[i].y1][j] = i;
    ans[i].s++;
  }
}
void moveDown(int i) {
  bool ok = true;
  for (int j=ans[i].x1; j<=ans[i].x2; j++) {
    if (!(ans[i].y2+1 <= 10000 && area[ans[i].y2+1][j] == -1)) {
      ok = false;
      break;
    }
  }
  if (!ok) return;
  ans[i].y2++;
  for (int j=ans[i].x1; j<=ans[i].x2; j++) {
    area[ans[i].y2][j] = i;
    ans[i].s++;
  }
}

void calcArea(int i) {
  if (ans[i].s >= ad[i].r*0.9) okArea[i] = true;
}


bool isTimeLimit(clock_t start) {
  clock_t end = clock();
  const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
  if (time >= 4500) return true;
  else return false;
}

void output() {
  rep(i, n) {
    cout << ans[i].x1 << " " << ans[i].y1 << " " << ans[i].x2 << " " << ans[i].y2 << endl;
  }
}



int main() {
	// 入力
	input();
  init();
  int cnt = 0;
	while (1) {
    rep(i, n) {
      if (okArea[i]) continue;
      moveLeft(i);
      moveRight(i);
      moveUp(i);
      moveDown(i);
      calcArea(i);
    }
    if (cnt%1000 == 0) {
      if (isTimeLimit(start)) break;
    }
    cnt++;
	}
  output();

	return 0;
}