#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()
#define mk make_pair
typedef int64_t ll;
#define P pair<ll,ll>
#define vi vector<ll>
#define vii vector<vector<ll> >
#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define rep2(i,m,n) for(ll (i)=(m); (i)<(ll)(n); (i)++)
const ll INF = 1LL<<32;

int main() {
  ll n;
  cin >>n;
  vii dat(n,vi(3,0));
  rep(i,n) {
    rep(j,3) cin >> dat.at(i).at(j);
  }
  vii ans(n,vi(4,0));
  
  rep(i,n) {
    ans.at(i).at(0) = dat.at(i).at(0);
    ans.at(i).at(1) = dat.at(i).at(1);
    ans.at(i).at(2) = dat.at(i).at(0)+1;
    ans.at(i).at(3) = dat.at(i).at(1)+1;
  }
  vector<bool> leftup(n,true);
  rep(i,n) {
    ll state_a = dat.at(i).at(0);
    ll state_b = dat.at(i).at(1);
    rep(j,n) {
      if(dat.at(j).at(0)<=state_a && dat.at(j).at(1)<=state_b && i!=j) {
        leftup.at(i) = false;
        break;
      }
    }
  }
  ll des;
  double genten = 1;
  rep(i,n) {
    double mini = min(dat.at(i).at(2),ans.at(i).at(2)*ans.at(i).at(3));
    double maxi = max(dat.at(i).at(2),ans.at(i).at(2)*ans.at(i).at(3));
    if(leftup.at(i) && 1-mini/maxi<genten) {
      genten = 1-mini/maxi<genten;
      des = i;
    }
  }
  
  ans.at(des).at(0) = 0;
  ans.at(des).at(1) = 0;
  
  rep(i,n) {
    rep(j,3) {
      cout << ans.at(i).at(j)<< " ";
    }
    cout << ans.at(i).at(3) << endl;
  }
}
#include<bits/stdc++.h>
using namespace std;

int main()
{
ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    // reading starts 
    int n;
    cin >> n;
    vector<vector<int>> a;
    set<int> xaxis, yaxis;
    // xaxis.insert(10000);
    // yaxis.insert(10000);
    for(int i = 0; i < n; ++i){
        vector<int> b;
        int x; 
        for(int j = 0; j < 3; ++j) cin >> x, b.push_back(x);
        a.push_back(b);
    }
    //reading ends 

    vector<vector<int>> bout(n, vector<int>(4,0));
    
    vector<int> aa;
    for(int i = 0 ;i  < n; ++i) aa.push_back(i);
    sort(aa.begin(), aa.end(), [&] (const int x, int y) {return a[x][3] < a[y][3];});
    bout[aa[0]][0] = 0;
    bout[aa[0]][1] = 0;
    bout[aa[0]][2] = 9999;
    bout[aa[0]][3] = 9999;
    int x = 0;
    for(int i = 1; i < n; ++i){
        bout[aa[i]][0] = 9999;
        bout[aa[i]][1] = x;
        bout[aa[i]][2] = 10000;
        bout[aa[i]][3] = x+1;
        ++x;
    }
    //output starts (b)
    vector<vector<int>> & b = bout;
    int m_b = b.size();
    for(int i = 0; i < m_b ; ++i)
    {
        for(int j = 0; j <4;++j)
        cout << b[i][j] << " ";
        cout <<endl;
    }

    return 0;
}