#include <bits/stdc++.h>
using namespace std; 
#define all(c) c.begin(),c.end()
#define sz(x) int(x.size())
#define ar array
typedef long long ll ; 
typedef vector<int> vi;
#define mod 1000000007
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll exp(ll x,ll y){
  x%=mod;
  ll res=1;
  while(y){
    if(y&1)
    res=res*x%mod;
    x=x*x%mod;
    y>>=1;
  }
  return res;
}
ll fact(ll n){
  ll res=1;
  for(ll i=2;i<=n;++i)
  (res*=i)%=mod;
  return res;
}
bool isprime(ll n){
  if(n<=1) return 0;
  for(ll i=2;i*i<=n;++i)
  if(n%i==0) return 0;
  return 1;
}

int main()
{
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
ll k,n,m;
cin>>k>>n>>m;
vector<ll>v(k);
for(int i=0;i<k;++i) cin>>v[i];
using ld=long double;
ld l=0,r=1;
for(int _=1;_<=150;++_){
  ld mid=(l+r)/2;
  ll up=0,dn=0;
  for(int i=0;i<k;++i){
  ll mx=0,mn=0;
  mx=(ll)((((ld)(m*v[i]))/n+(mid*(ld)m)));
  mn=(ll)(ceil(((ld)(m*v[i]))/n-(mid*(ld)m)));
  if(mn<0) mn=0;
  if(mx<0) mx=-mod;
  up+=mx;
  dn+=mn;
  }
  if(up>=m&&dn<=m) r=mid;
  else l=mid;
}
 vector<ll>ans(k);
ll req=m;
  for(int i=0;i<k;++i){
  ll mx=0,mn=0;
  mx=(ll)((((ld)(m*v[i]))/n+r*(ld)m));
  mn=(ll)(ceil(((ld)(m*v[i]))/n-r*(ld)m));
  if(mn<0) mn=0;
  req-=mn;
  ans[i]=mn;
  }
    for(int i=0;i<k;++i){
  ll mx=0,mn=0;
  mx=(ll)((((ld)(m*v[i]))/n+r*(ld)m));
  mn=(ll)(ceil(((ld)(m*v[i]))/n-r*(ld)m));
  if(mn<0) mn=0;
  ll p=min(req,mx-ans[i]);
  ans[i]+=p;
  req-=p;
  } 
  for(auto c:ans) cout<<c<<" "; 
return 0;
}

//#include <atcoder/all>
//using namespace atcoder;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define ALL(v) v.begin(), v.end()
#define bit(n) (1LL<<(n))
#define FIX(d) fixed << setprecision(d)
using P = pair<int, int>;
using LP = pair<ll, ll>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const ll LINF = (1LL<<60);
const double EPS = 1e-10;

unsigned int xor128(){
  static unsigned int x=123456789,y=362436069,z=521288629,w=88675123;
  unsigned int t = (x^(x<<11));
  x=y; y=z; z=w; 
  return( w=(w^(w>>19))^(t^(t>>8)) );
}

int n;
int cx[200], cy[200], r[200];
int a[200], b[200], c[200], d[200];

ll score(){
  double sc = 0.0;
  REP(i,n){
    int area = (c[i]-a[i]) * (d[i]-b[i]);
    double tmp = 1.0 - (double)min(area,r[i])/max(area,r[i]);
    sc += 1.0 - tmp*tmp;
  }
  sc *= 1e9;
  sc /= n;
  return (ll)round(sc);
}

void init(){
  REP(i,n){
    a[i] = cx[i];
    b[i] = cy[i];
    c[i] = cx[i]+1;
    d[i] = cy[i]+1;
  }
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  REP(i,n) cin >> cx[i] >> cy[i] >> r[i];

  int ti = clock();
  init();
  ll mx = score();
  //cout << mx << endl;
  vector<bool> full(n, false);
  while(clock() - ti < 495 * CLOCKS_PER_SEC / 100){ 
    REP(loop, 300){
      int ind = xor128() % n;
      if(full[ind]) continue;
      int xy = xor128() % 2;
      bool minus = false, plus = false;
      if(xy==0){
        REP(i,n){
          if(i==ind) continue;
          if(max(a[i],a[ind]-1)<min(c[i],c[ind]) && max(b[i],b[ind])<min(d[i],d[ind])){
            minus = true;
          }
          if(max(a[i],a[ind])<min(c[i],c[ind]+1) && max(b[i],b[ind])<min(d[i],d[ind])){
            plus = true;
          }
        }

        if(c[ind]<10000 && !plus){ 
          c[ind]++;
          if(!chmax(mx, score())) c[ind]--;
        }else if(a[ind]>0 && !minus){ 
          a[ind]--;
          if(!chmax(mx, score())) a[ind]++; 
        }
      }else{
        REP(i,n){
          if(i==ind) continue;
          if(max(a[i],a[ind])<min(c[i],c[ind]) && max(b[i],b[ind]-1)<min(d[i],d[ind])){
            minus = true;
          }
          if(max(a[i],a[ind])<min(c[i],c[ind]) && max(b[i],b[ind])<min(d[i],d[ind]+1)){
            plus = true;
          }
        }
        if(d[ind]<10000 && !plus){ 
          d[ind]++;
          if(!chmax(mx, score())) d[ind]--;
        }else if(b[ind]>0 && !minus){ 
          b[ind]--;
          if(!chmax(mx, score())) b[ind]++; 
        }
      }
      
      bool xp = false, xm = false;
      bool yp = false, ym = false;
      REP(i,n){
        if(i==ind) continue;
        if(max(a[i],a[ind]-1)<min(c[i],c[ind]) && max(b[i],b[ind])<min(d[i],d[ind])){
          xm = true;
        }
        if(max(a[i],a[ind])<min(c[i],c[ind]+1) && max(b[i],b[ind])<min(d[i],d[ind])){
          xp = true;
        }
        if(max(a[i],a[ind])<min(c[i],c[ind]) && max(b[i],b[ind]-1)<min(d[i],d[ind])){
          ym = true;
        }
        if(max(a[i],a[ind])<min(c[i],c[ind]) && max(b[i],b[ind])<min(d[i],d[ind]+1)){
          yp = true;
        }
      }
      if(xp&xm&yp&ym) full[ind] = true;
      
    }
    //cout << mx << endl;
  }
  //cout << mx << endl;
  REP(i,n) cout << a[i] << " " << b[i] << " " << c[i] << " " << d[i] << '\n';
  return 0;
}
