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

void ans_add(string &t,vector<int>i){
  t+=to_string(i[0])+' '+to_string(i[1])+' '+to_string(i[2])+' '+to_string(i[3])+'\n';
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin>>n;
  vector<vector<int>>ad(n,vector<int>(4));
  for(int i=0;i<n;i++){
    cin>>ad[i][1]>>ad[i][2]>>ad[i][0];
    ad[i][3]=i;
  }
  sort(ad.begin(),ad.end(),[](vector<int> a,vector<int> b){
    return abs(a[0]-9999*50)<abs(b[0]-9999*50);
  });
  vector<vector<int>>ans(n,vector<int>(4));
  vector<bool>al(n);
  int base=(10000/n);
  for(int i=0;i<n;i++){
    if(al[(ad[i][1])/base]){
      ans[ad[i][3]]=(vector<int>){i,9998,i+1,9999};
    }else{
      if(ad[i][0]>=base*9999){

        ans[ad[i][3]]=(vector<int>){(ad[i][1])/base*base,0,min((ad[i][1])/base*base+base,9999),9998};

      }

      else{
        int b=min((ad[i][1])/base*base+base,9999)-(ad[i][1])/base*base;
        int u=max(0,ad[i][2]-ad[i][0]/base+1);
        int d=min(9998,ad[i][0]/b+u);
        if(abs((d-u)*b-ad[i][0])>abs((d-u+1)*b-ad[i][0])){
          d=min(9998,d+1);
        }
        ans[ad[i][3]]=(vector<int>){(ad[i][1])/base*base,u,min((ad[i][1])/base*base+base,9999),d};
      }

      al[(ad[i][1])/base]=true;
    }
  }
  string ret="";
  for(auto i:ans){
    ans_add(ret,i);
  }
  cout<<ret;
}
#define pb push_back
#define mp make_pair
#define fi first
#define se second 
#define all(...) begin(__VA_ARGS__) , end(__VA_ARGS__)
#define boost {ios_base::sync_with_stdio(false); cin.tie(); cout.tie();}

#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define random_shuffle(...) shuffle(__VA_ARGS__, rng)

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector <int> vi;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
constexpr ll nax = 2e5+6969, INF = 2e9+6969;

int n,point[2][205],rec[205],ans[4][205];
bool br[10005][10005];
priority_queue<pair<ld,int>> q;

ld add(ll s, ll r, ll x)
{
	ld tmp = (ld)((r-s)*2 - x) / r;
	return tmp * x / r;
}

int random(int a, int b) 
{
	return uniform_int_distribution<int>(a,b)(rng);
}

int main()
{	
	scanf("%d", &n);
	for(int i=0;i<n;i++) 
	{
		scanf("%d%d%d", &point[0][i], &point[1][i], &rec[i]);
		if(br[point[0][i]][point[1][i]] == 0) 
		{
			ans[0][i] = point[0][i];
			ans[1][i] = point[1][i];
			ans[2][i] = point[0][i]+1;
			ans[3][i] = point[1][i]+1;
			br[point[0][i]][point[1][i]] = 1;
			q.push(mp(add(1, rec[i], 1), i));
		}
	}
	int REPS = 1000'000;
	for(int i=0;;i++) 
	{
		if(q.empty()) break;
		vi changes;
		for(int j=0;j<15;j++) 
		{
			if(q.empty()) break;
			changes.pb(q.top().se);
			q.pop();
		}
		random_shuffle(all(changes));
		for(auto who: changes)
		{
		int X = ans[2][who] - ans[0][who];
		int Y = ans[3][who] - ans[1][who];
		bool lf,rg,up,dw;
		lf = rg = up = dw = 0;
		{
		if(ans[1][who] > 0) 
		{
			up = 1;
			for(int i=ans[0][who];i<ans[2][who];i++) 
			{
				if(br[i][ans[1][who]-1]) 
				{
					up = 0;
					break;
				}
			}
		}
		if(ans[3][who] < 10000)
		{
			dw = 1;
			for(int i=ans[0][who];i<ans[2][who];i++) 
			{
				if(br[i][ans[3][who]]) 
				{
					dw = 0;
					break;
				}
			}
		}
		if(ans[0][who] > 0) 
		{
			lf = 1;
			for(int i=ans[1][who];i<ans[3][who];i++) 
			{
				if(br[ans[0][who]-1][i]) 
				{
					lf = 0;
					break;
				}
			}
		}
		if(ans[2][who] < 10000)
		{
			rg = 1;
			for(int i=ans[1][who];i<ans[3][who];i++) 
			{
				if(br[ans[2][who]][i]) 
				{
					rg = 0;
					break;
				}
			}
		}
	}
		if(X*(Y+1) > rec[who]) up = dw = 0;
		if((X+1)*Y > rec[who]) lf = rg = 0;
		if((((lf|rg)|up)|dw) == 0) continue;
		vi options;
		if(up) options.pb(0);
		if(dw) options.pb(1);
		if(lf) options.pb(2);
		if(rg) options.pb(3);
		int choice = options[random(0,options.size()-1)];
				if(choice == 0)
				{
					ans[1][who]--;
					for(int i=ans[0][who];i<ans[2][who];i++) br[i][ans[1][who]] = 1;
					int R = X*(Y+1);
					if(R < rec[who]) 
					{
						q.push(mp(add(R, rec[who], (X+1+Y)/2), who));
					}
				}
				if(choice == 1)
				{
					for(int i=ans[0][who];i<ans[2][who];i++) br[i][ans[3][who]] = 1;
					ans[3][who]++;
					int R = X*(Y+1);
					if(R < rec[who]) 
					{
						q.push(mp(add(R, rec[who], (X+1+Y)/2), who));
					}
				}
			if(choice == 2)
			{
				ans[0][who]--;
				for(int i=ans[1][who];i<ans[3][who];i++) br[ans[0][who]][i] = 1;
				int R = (X+1)*Y;
				if(R < rec[who]) 
				{
					q.push(mp(add(R, rec[who], (X+1+Y)/2), who));
				}
			}
			if(choice == 3)
			{
				for(int i=ans[1][who];i<ans[3][who];i++) br[ans[2][who]][i] = 1;
				ans[2][who]++;
				int R = (X+1)*Y;
				if(R < rec[who]) 
				{
					q.push(mp(add(R, rec[who], (X+Y+1)/2), who));
				}
			}
		}
	}
	PII last = mp(0,0);
	for(int i=0;i<n;i++) 
	{
		if(ans[2][i] == ans[3][i] && ans[2][i] == 0) 
		{
			for(int x = last.fi; x <= 10000; x++) 
			{
				for(int y = 0; y <= 10000; y++) 
				{
					if(br[x][y] == 0) 
					{
						ans[0][i] = x;
						ans[1][i] = y;
						ans[2][i] = x+1;
						ans[3][i] = y+1;
						last = mp(x,y);
					}
				}
			}
		}
		for(int j=0;j<4;j++) cout << ans[j][i] << " " ;
		puts("");
	}
	
	return 0;
}
