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

struct desire
{
  int x;
  int y;
  int r;
};
struct place
{
  vector<int> d;
  int s;
};

void input(vector<desire> &ads_de, vector<place> &ads_pl, int N);
void output(vector<place> &ads_pl, int N);
void expand(vector<desire> &ads_de, vector<place> &ads_pl, int N);
bool can_expand(vector<place> &ads_pl, int N, int vertex, int company);

int main()
{
  int N;
  cin >> N;
  vector<desire> ads_de(N);
  vector<place> ads_pl(N);
  input(ads_de, ads_pl, N);
  expand(ads_de, ads_pl, N);
  output(ads_pl, N);
}

void input(vector<desire> &ads_de, vector<place> &ads_pl, int N)
{
  for (int i = 0; i < N; i++)
  {
    cin >> ads_de.at(i).x >> ads_de.at(i).y >> ads_de.at(i).r;
    ads_pl.at(i).d.push_back(ads_de.at(i).x);
    ads_pl.at(i).d.push_back(ads_de.at(i).y);
    ads_pl.at(i).d.push_back(ads_de.at(i).x+1);
    ads_pl.at(i).d.push_back(ads_de.at(i).y+1);
    ads_pl.at(i).s = 1;
  }
}
void output(vector<place> &ads_pl, int N)
{
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < 4; j++) cout << ads_pl.at(i).d.at(j) << " ";
    cout << "\n";
  }
}
void expand(vector<desire> &ads_de, vector<place> &ads_pl, int N)
{
  int check = 1;
  int expand_s;
  while (check)
  {
    check = 0;
    for (int i = 0; i < 4; i++)
    {
      for (int j = 0; j < N; j++)
      {
        if (can_expand(ads_pl,N,i,j))
        {
          expand_s = ads_pl.at(j).s+abs(ads_pl.at(j).d.at((i+1)%4)-ads_pl.at(j).d.at((i+3)%4));
          if ((double)min(expand_s,ads_de.at(j).r)/max(expand_s,ads_de.at(j).r) > (double)min(ads_pl.at(j).s,ads_de.at(j).r)/max(ads_pl.at(j).s,ads_de.at(j).r))
          {
            ads_pl.at(j).s = expand_s;
            ads_pl.at(j).d.at(i) += pow(-1,i/2+1);
            check = 1;
          }
        }
      }
    }
  }
}

bool can_expand(vector<place> &ads_pl, int N, int vertex, int company)
{
  int side_min, side_max, each_min, each_max, dir;
  bool ret;

  side_min = min(ads_pl.at(company).d.at((vertex+1)%4),ads_pl.at(company).d.at((vertex+3)%4));
  side_max = max(ads_pl.at(company).d.at((vertex+1)%4),ads_pl.at(company).d.at((vertex+3)%4));
  dir = pow(-1,vertex/2+1);
  if (ads_pl.at(company).d.at(vertex)+dir<0 || ads_pl.at(company).d.at(vertex)+dir>10000)
    return false;
  ret = true;
  for (int i = 0; i < N; i++)
  {
    if (i == company) continue;
    each_min = min(ads_pl.at(i).d.at((vertex+1)%4),ads_pl.at(i).d.at((vertex+3)%4));
    each_max = max(ads_pl.at(i).d.at((vertex+1)%4),ads_pl.at(i).d.at((vertex+3)%4));
    if (side_max <= each_min || side_min >= each_max) continue;
    if ((ads_pl.at(company).d.at(vertex)+dir)*dir > ads_pl.at(i).d.at((vertex+2)%4)*dir && (ads_pl.at(company).d.at((vertex+2)%4))*dir < ads_pl.at(i).d.at(vertex)*dir)
    {
      ret = false;
      break;
    }
  }
  return ret;
}

#include <iostream>
#include <cstdlib>
#include<vector>
#include<memory>
#include<algorithm>
 
struct Box{
    int x;
    int y;
    int r;
    int a,b,c,d;
};
int Len = 10000;
struct Col{
    int x;
    int x_min;
    int x_max;
    std::vector<std::shared_ptr<Box>> elem;
};


double count_score(Col const&c){
    double t = 0;
    if(c.x_min <= c.x && c.x+1 <= c.x_max){
        for (auto p : c.elem) {
            auto s = (c.x_max - c.x_min) * Len / c.elem.size();
            auto xten = std::min<int>(s, p->r) / (double)p->r;
            t += 1 - (1 - xten) * (1 - xten);
        }
    }else{
        t = - (std::max(c.x+1 - c.x_max, c.x_min - c.x) * 100);
    }

    return t;
}


int main()
{
    std::vector<std::shared_ptr<Box>> input;
    int n;
    std::cin>>n;
    for(int i=0;i<n;++i){
        Box b;
        std::cin>>b.x>>b.y>>b.r;
        input.push_back(std::make_shared<Box>(b));
    }

    std::vector<std::vector<std::shared_ptr<Box>>> backet(Len);
    for(auto p : input){
        backet[p->x].push_back(p);
    }
    
    std::vector<std::shared_ptr<Col>> col_list;
    {
        Col c;
        c.x_min = -1;
        c.x = -1;
        col_list.push_back(std::make_shared<Col>(c));
    }

    for(auto&v: backet){
        if(v.size() > 0){
            Col c;
            c.x = v[0]->x;
            c.elem = v;
            col_list.push_back(std::make_shared<Col>(c));
        }
    }

    {
        Col c;
        c.x = Len;
        c.x_max = Len + 1;
        col_list.push_back(std::make_shared<Col>(c));
    }

    for(int i=0;i+1<col_list.size();++i){
        auto m = (col_list[i]->x + col_list[i+1]->x)/2;
        col_list[i]->x_max = m;
        col_list[i+1]->x_min = m;
    }

    for(int t= 0 ;t<1000;++t){
        for(int i=0;i+1<col_list.size();++i){
            auto count = [&](int shift_val){ 
                auto lshift1 = *(col_list[i]);
                auto lshift2 = *(col_list[i+1]);
                lshift1.x_max += shift_val;
                lshift2.x_min += shift_val;
                return count_score(lshift1) + count_score(lshift2);
            };
            auto lshift = count(-1);
            auto noshift = count(0);
            auto rshift = count(1);
            if(lshift >= rshift && lshift >= noshift){
                col_list[i]->x_max+=-1;
                col_list[i+1]->x_min+=-1;
            }else if(lshift <= rshift && rshift >= noshift){
                col_list[i]->x_max+=1;
                col_list[i+1]->x_min+=1;
            }
        }
    }

    for(auto c: col_list){
        for(int i =0;i<c->elem.size();++i){
            int y_len = c->elem[i]->r/(c->x_max - c->x_min);
            int y_min = i==0? 0 : c->elem[i]->y;
            int y_max = i+1==c->elem.size() ? Len : c->elem[i+1]->y;
            if(y_len > y_max - y_min){
                c->elem[i]->b = y_min;
                c->elem[i]->d = y_max;
            }else{  
                auto bottom = c->elem[i]->y + y_len;
                if(bottom > y_max){
                    bottom = y_max;
                }
                c->elem[i]->b = bottom - y_len;
                c->elem[i]->d = bottom;
            }
            c->elem[i]->a = c->x_min;
            c->elem[i]->c = c->x_max;
        }
    }
    for(auto p: input){
        std::cout<<p->a<<" "<<p->b<<" "<<p->c<<" "<<p->d<<"\n";
    }
}
